Rack Assy Frame

I am building and I am having problems with the stack frame. One of the requirements is passing parameters using the stack, not registers. I am trying to pass a variable by reference, and then change the value of this variable in the procedure. Here is what I still have. WriteStringand ReadDec- from the library (Irvine), which comes with the book.

.data
numVal  DWORD ?
.code
main PROC
    PUSH    OFFSET numVal
    CALL    GetNumber
    exit
main ENDP
GetNumber PROC
    PUSH    edx
    PUSH    ebp
    MOV     ebp, esp

    CALL    ReadDec                ; gets what the user inputs and puts in eax
    MOV     [ebp+12], eax
    ; MOV    numVal, eax           ; this works just fine

    POP     ebp
    POP     edx
    RET     4
GetNumber ENDP
END main

, numVal - , 0, , . , , ebp+12, , numVal. , , , numVal ? , MOV numVal, eax ?

PS. , , .

. , , ..

+4
1

"" .

GetNumber PROC
    PUSH    edx
    PUSH    ebp
    MOV     ebp, esp

    CALL    ReadDec                ; gets what the user inputs and puts in eax
    MOV     edx, [ebp+12] ; edx now has "offset numVal"
    mov     [edx], eax ; put result of ReadDec there
    ; MOV    numVal, eax           ; this works just fine

    POP     ebp
    POP     edx
    RET     4
GetNumber ENDP

>

edx - , , , - "". !

+4

All Articles