I created a simple code to make a summation (currently the first 20 numbers). Everything goes fine, even the functions I made to print a number. There's a single problem: I can't use both words I allocated at .data
.
section .data
total dw 0
index dw 1
If I add index
to .data
, the value of [total]
goes from 0 to 65536. index
's is still 1, and I don't have any clue of why this is happening.
I removed the loops and instructions in _sum20
to shorten the pasted code (I tested it).
section .data
total dw 0
index dw 1
_start:
call _sum20
call _printInt
end
_sum20:
mov rax, [total] ; rax = 65536
ret
In the code above, [total]
has a value of 65536
section .data
total dw 0
_start:
call _sum20
call _printInt
end
_sum20:
mov rax, [total] ; rax = 0
ret
Here, [total]
's value is 0