News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

passing reg::reg

Started by ecube, January 13, 2007, 01:10:30 AM

Previous topic - Next topic

ecube


GregL

Check this out. Note the INVOKE with eax::edx and edx::eax.


.586
.MODEL FLAT, stdcall
OPTION CASEMAP:NONE

INCLUDE windows.inc

INCLUDE kernel32.inc
INCLUDE msvcrt.inc

INCLUDELIB kernel32.lib
INCLUDELIB msvcrt.lib

someproc PROTO STDCALL,:QWORD,:QWORD

xqword$ MACRO xqwordvalue:REQ
    ; unsigned hex qword
    LOCAL buffer
    .DATA?
        buffer BYTE 20 dup(?)
    IFNDEF xqwfmt   
    .DATA   
        xqwfmt    BYTE "%I64X", 0
    ENDIF   
    .CODE
        push  DWORD PTR [xqwordvalue+4]
        push  DWORD PTR [xqwordvalue+0]
        push  OFFSET xqwfmt
        push  OFFSET buffer
        call  crt_sprintf
        add   esp, 16
        EXITM <OFFSET buffer>
ENDM

.CODE

start:

    mov eax, 0DEADBEEFh
    mov edx, 012345678h
   
    INVOKE someproc, eax::edx, edx::eax
   
    INVOKE ExitProcess, 0

someproc PROC qw1:QWORD, qw2:QWORD
    INVOKE crt_puts, xqword$(qw1)
    INVOKE crt_puts, xqword$(qw2)
    ret
someproc ENDP

END start


ecube

ahh using it with qwords makes more sense, alright thanks a lot guys  :U

sinsi

Used to use it a lot in the 16-bit days.

strlen PROTO C string:FAR PTR BYTE
...
INVOKE strlen,ES::BX
...

Thanks for the reminder Greg :U.
Light travels faster than sound, that's why some people seem bright until you hear them.