Ensamblaje x86: antes de realizar una llamada al sistema en Linux ¿Debería guardar todos los registros?

Tengo el siguiente código que abre un archivo, lo lee en un búfer y luego cierra el archivo.

La llamada al sistema de archivo cerrado requiere que el número del descriptor de archivo esté en el registro ebx. El registro ebx obtiene el número de descriptor de archivo antes de realizar la llamada al sistema de lectura. Mi pregunta es si debo guardar el registro ebx en la pila o en algún lugar antes de hacer la llamada al sistema de lectura (¿podría int 80h eliminar el registro ebx?). ¿Y luego restaurar el registro ebx para la llamada de cierre del sistema? ¿O el código que tengo debajo es bueno y seguro?

He ejecutado el siguiente código y funciona, simplemente no estoy seguro de si generalmente se considera una buena práctica de ensamblaje o no porque no guardo el registro ebx antes de la llamada de lectura int 80h.

;; open up the input file 
mov eax,5        ; open file system call number
mov ebx,[esp+8]  ; null terminated string file name, first command line parameter
mov ecx,0o       ; access type: O_RDONLY
int 80h          ; file handle or negative error number put in eax
test eax,eax
js Error         ; test sign flag (SF) for negative number which signals error

;; read in the full input file
mov ebx,eax            ; assign input file descripter
mov eax,3              ; read system call number
mov ecx,InputBuff      ; buffer to read into
mov edx,INPUT_BUFF_LEN ; total bytes to read
int 80h
test eax,eax
js Error               ; if eax is negative then error
jz Error               ; if no bytes were read then error
add eax,InputBuff      ; add size of input to the begining of InputBuff location
mov [InputEnd],eax     ; assign address of end of input

;; close the input file
;; file descripter is already in ebx
mov eax,6       ; close file system call number
int 80h         

Respuestas a la pregunta(2)

Su respuesta a la pregunta