I am new to assembly and working with the stack so my knowledge may not be the greatest. I am writing a procedure that accepts two 16-bit operands by value and one operand by OFFSET. The procedure will calculate the sum of the two operands and will store the result into memory at the OFFSET specified. In this assignment, I cant use main and data hence the weird format. After I move the variables into registers for later use I can not find them at any address. Using a debugging tool I find that eax,edx,abx are storing completely different values when decoy is used. What can I do to pull out the values I need to properly calculate them in my procedure?
.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
cmp dest, 0
je L1
cmp dest, 1
je L2
L1:
mov eax,[ebp + 12]
mov edx, [ebp + 14]
mov ebx, [ebp + 8]
call decoy
l2:
;ll encrypt
ret 14
compute ENDP
;-------------------------------------------------------------------------
;Decoy
;-------------------------------------------------------------------------
decoy PROC
push ebp
mov ebp,esp
mov eax, 0
;mov ebx,[ebp + 12]
;mov edx, [ebp + 8]
;movsx edx, dx
mov edx, [ebp + 8]
mov ebx, [ebp + 12]
;add dx, [ebp + 10]
movsx eax, dx
;mov [ebx], eax
call WriteInt
pop ebp
ret 12
decoy ENDP