News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Stack frame test

Started by hutch--, July 05, 2016, 01:19:49 PM

Previous topic - Next topic

hutch--

I have put aside Vasily's macros for the moment to try out a normal stack frame using RBP addressing. Seems to work OK.


; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
   
    option casemap:none

    include \masm64\include\win64.inc

    include \masm64\include\kernel32.inc
    include \masm64\include\user32.inc
    include \masm64\include\msvcrt.inc

    includelib \masm64\lib\user32.lib   
    includelib \masm64\lib\kernel32.lib
    includelib \masm64\lib\msvcrt.lib

  .data
    message db "Hello World with stack frame.", 0
    caption db "Direct argument load", 0
    ttitle  db "With LOCAL arguments",0

  .code

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

OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE

main proc

    push rbp
    mov rbp, rsp        ; create stack frame

    sub rbp, 128        ; allocate stack space

    mov rcx, 0
    lea rdx, message
    lea r8, caption
    mov r9, 0
    call MessageBox

  ; ------------------------------------
  ; write arguments to LOCAL stack space
  ; ------------------------------------
    mov QWORD PTR [rbp-64], 0

    lea rax, message
    mov QWORD PTR [rbp-72], rax

    lea rax, ttitle
    mov QWORD PTR [rbp-80], rax

    mov QWORD PTR [rbp-88], MB_OK
  ; ------------------------------------

    mov rcx, [rbp-64]   ; handle
    mov rdx, [rbp-72]   ; display text
    mov r8,  [rbp-80]   ; title
    mov r9,  [rbp-88]   ; style
    call MessageBox     ; call MessageBox API function

    xor rcx, rcx
    call ExitProcess

    mov rsp, rbp        ; terminate stack frame
    pop rbp

    ret

main endp

OPTION PROLOGUE:PrologueDef
OPTION EPILOGUE:EpilogueDef

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

end