Search code examples
assemblyx86masm

Access writing violation when using INVOKE


currently messing around with x86 assembly and I'm having some issues identifying the reason why the following code is causing a write access violation:


Solution

  • main PROC
    INVOKE minmax,
            OFFSET array,
            LENGTHOF array,
            OFFSET msg1,
            OFFSET msg2
    
    
    main ENDP
    

    Look at your proc carefully... Your missing something, do you realize what? Well, your missing a ret right before main endp! Without a ret the cpu will continue executing what ever is after main endp.

    main PROC
    INVOKE minmax,
            OFFSET array,
            LENGTHOF array,
            OFFSET msg1,
            OFFSET msg2
    
    ret
    main ENDP
    

    is correct