Why do register arg values need to be re-assigned in NASM after an int 0x80 system call?

34 views Asked by At

So I'm still learning NASM assembly, I'm far from knowledgeable, which you can probably tell from this literal hello world program, but I'm curious about an issue. When I run:

section .text:
    global _start

_start:
    mov edx, len
    mov ecx, msg
    mov ebx, 1
    mov eax, 4
    int 0x80
    mov edx, len2
    mov ecx, msg2
    mov ebx, 1
    mov eax, 4
    int 0x80
    mov eax, 1
    int 0x80

section .data:
    msg db "Let's test this thing!"
    len equ $ - msg
    msg2 db "This is the second line."
    len2 equ $ - msg2

If I omit the second mov eax, 4 and mov ebx, 1, it prints the first line, but not the second line.

When I do re-assign ebx and eax before running the second one, to the same values as originally, works fine and prints both lines. (This is the version in the code block.)

I don't really understand why this is the case - the registers have already been set and I haven't changed them, so why do I need to re-assign them to the same values that they should already have before running the interrupt again? I'd love some help, because this really doesn't make sense to me.

0

There are 0 answers