'Need help pulling DX out of the stack and putting the value on a 32 bit OFFSET of a signed DWORD
Hi everyone I am new to x86 architecture for assembly as well as working on the stack. What I want to do is add the two operand word values together to get 26 and to change the dest dword into this. I am not too comfortable with working with the stack so my work is a bit of a jumble.My assignment does not allow global variables hence the pushing of both operands. What I had tried to do was dereference both operands and put them onto dx for later. I wanted to in the second procedure get dx wherever it is on the stack and movsx it to the eax(which should go to dest) but neither my dest or operands will show the correct value and will crash the program. Right now I am using dx directly but need it on stack instead.
.data
operand1 WORD 46
operand2 WORD -20
dest DWORD 0
.code
main PROC
push operand1 ;14
push operand2 ;12
push OFFSET dest ;8
call compute
exit
main ENDP
;-------------------------------------------------------------------------
;Compute
;-------------------------------------------------------------------------
compute PROC
mov dx, [ebp + 12]
add dx, [ebp + 14]
push dx
mov eax, [ebp + 8]
call decoy
ret
compute ENDP
;-------------------------------------------------------------------------
;Decoy
;-------------------------------------------------------------------------
decoy PROC
push ebp
mov ebp,esp
;[] dereference
mov eax,[ebp + 6] ;contains OFFSET
mov [ebx], eax
mov esp,ebp
;;Find DX on register and mov that onto eax
movsx eax, dx
call WriteInt
pop ebp
decoy ENDP
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
