Variables from .data section are read incorrectly

Viewed 25

I try to push the a, b and c variables (that are defined in .data section) onto the stack. They are pushed successfully but their values are incorrect. It leads to unpredictable results (it works very similar to a situation where C++ variables aren't initialized and the system sets them up randomly).

I'm a beginner in MASM, so I don't know how to use variables from .data section. Please help me with this problem and explain how to do it correctly.

    extern _asm_func: PROC
    
    public linker
    
    .data
        a QWORD 24
        b QWORD 13
        c QWORD 10
    
    .code
        linker PROC STDCALL
            push c
            push b
            push a
    
            call _asm_func
    
            ret 
        linker ENDP
    end

P.S. the _asm_func is a C function that is called from MASM.

0 Answers
Related