Question

I need to know what the last two lines of code do,everything compiles and works as expected. My section declarations are:

SECTION .data
prompt: db      "Enter 10 digits: "
plen:   equ     $-prompt
SECTION .bss
digits: equ     10
inbuf:  resb    digits + 2
SECTION .text

The code snippet that I don't understand is:

mov     al, ah              ; move AH to AL
add     al, '0'             ;add the ascii value of 0 (48) to al, store in al
mov     [inbuf+10], al      ;????
mov byte    [inbuf+11], 10  ;?????

Thank you

Was it helpful?

Solution

Since everything is a byte, there's no endianness involved.

These lines just do:

mov     [inbuf+10], al      ; store the digit
mov byte    [inbuf+11], 10  ; 10 (line feed) on the end

By the way, if there are digits in inbuf + 0 through inbuf + 10, that means you have 11 of them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top