so i have a variable of type DWORD: var2 DWORD 10000h,20000h,30000h,40000h
and my program is:
.data
var2 DWORD 10000h,20000h,30000h,40000h
.code
main PROC
mov eax, 0
mov ebx, 0
mov ecx, 0
mov edx, 0
mov eax, [var2]
mov ebx, [var2+4]
mov ecx, [var2+8]
mov edx, [var2+12]
add eax,ebx
add ecx, edx
add ecx, eax
call DumpRegs
exit
main ENDP
END main
Everything seems to work fine and my registers look like
But the actual answer should be 100000h shouldn't it be? as 10000 + 20000 + 30000 + 40000 is 100000h.
I have tried changing the registers, putting the total in a variable and then moving it to a register but I keep getting the same A0000.
But the actual answer should be 100000h shouldn't it be? as 10000 + 20000 + 30000 + 40000 is 100000h.
No, you are mistaken.
10000h + 20000h + 30000h + 40000h = A0000h
(To get 100000h, you'd have to add another 60000h at the end.)
You can try this in any calculator that supports hexadecimal (for example Windows', if you change to programmer mode). It's also logical from the fact that 1 + 2 + 3 + 4 = 10 in decimal, and 10 in decimal is A in hexadecimal.
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10
|1>|--2->|---3--->|-----4---->^^