The purpose of this program is to divide 36 by 10 and print the remainder (6) to the screen. The code I specified below doesn't work. I figured out that it was because on my marked line I was putting the value itself into ecx and not the address of that value in memory.
I later changed the code so that it first puts the value into a variable, and then did mov ecx, variable (which actually puts the address of the variable, not the value onto the register ecx). And it worked.
Why doing
mov ecx, variableputsvariables's address intoecx's value, but doingmov ecx, edxputsedx's value intoecxvalue?How can I specify the address of a register and put it in another register's value?
global _start
section .text
_start:
mov ebp, esp; for correct debugging
; division
mov eax,36
mov ebx,10
mov edx,0 ; cleaning edx before division
div ebx
add edx,0x30 ; converting the remainder (integer) into ascii digit
; display result
mov eax,4
mov ebx,1
mov ecx,edx ; pay attention to this line
mov edx,1
int 80h
; exit
mov eax,1
mov ebx,0
int 80h