Author Topic: Stack addressing test piece.  (Read 731 times)

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 5339
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Stack addressing test piece.
« on: July 17, 2016, 10:44:47 AM »
The documentation for how the 5 or more arguments passed to a procedure after the 4 registers in win 64 is lousy at best so I did a test piece to explore where passed stack arguments ended up. This is the test piece.


; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    include \masm64\include\masm64rt.inc

  ; --------------------------------------------
  ; arguments 5 through to 14 passed on the
  ; stack. name direct EBP based stack addresses
  ; with user recognisable names within a proc
  ; --------------------------------------------
    stackargs MACRO a5,a6,a7,a8,a9,aA,aB,aC,aD,aE
      .const
        IFNB <a5>
          a5 equ <[rbp+48]>
        ENDIF
        IFNB <a6>
          a6 equ <[rbp+56]>
        ENDIF
        IFNB <a7>
          a7 equ <[rbp+64]>
        ENDIF
        IFNB <a8>
          a8 equ <[rbp+72]>
        ENDIF
        IFNB <a9>
          a9 equ <[rbp+80]>
        ENDIF
        IFNB <aA>
          aA equ <[rbp+88]>
        ENDIF
        IFNB <aB>
          aB equ <[rbp+96]>
        ENDIF
        IFNB <aC>
          aC equ <[rbp+104]>
        ENDIF
        IFNB <aD>
          aD equ <[rbp+112]>
        ENDIF
        IFNB <aE>
          aE equ <[rbp+120]>
        ENDIF
      .code
    ENDM

    .code

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

entry_point proc

    .stack

    invoke testme,1,2,3,4,5,6,7,8,9,10

    waitkey

    void(ExitProcess,0)

    ret

entry_point endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

testme proc

    .stack

    stackargs five,six,seven,eight,nine,ten

    conout "five  = ",str$(five),lf
    conout "six   = ",str$(six),lf
    conout "seven = ",str$(seven),lf
    conout "eight = ",str$(eight),lf
    conout "nine  = ",str$(nine),lf
    conout "ten   = ",str$(ten),lf

    ret

testme endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    end


This is the output.


five  = 5
six   = 6
seven = 7
eight = 8
nine  = 9
ten   = 10
Press any key to continue...
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin: