The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: ecube on November 01, 2006, 11:41:50 PM

Title: conveting MAKEWORD c macro
Post by: ecube on November 01, 2006, 11:41:50 PM
#define MAKEWORD(a,b)   ((WORD)(((BYTE)(a))|(((WORD)((BYTE)(b)))<<8)))

how do you convert that to masm?

what it does
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowmacros/makeword.asp
Title: Re: conveting MAKEWORD c macro
Post by: GregL on November 02, 2006, 01:57:50 AM
#define MAKEWORD(a,b)   ((WORD)(((BYTE)(a))|(((WORD)((BYTE)(b)))<<8)))

Here's my quick shot at it.


MAKEWORD MACRO a:REQ, b:REQ
    mov al, a
    mov ah, b
    EXITM <ax>
ENDM   
Title: Re: conveting MAKEWORD c macro
Post by: ecube on November 02, 2006, 08:28:11 AM
Wow that simple, great! thanks again.
Title: Re: conveting MAKEWORD c macro
Post by: u on November 02, 2006, 10:54:17 AM
Also, if you're going to use only numbers as the "a" and "b" parameters:

MAKEWORD macro a,b
    exitm <((a)+((b) shl 8)) >
endm


invoke func1,MAKEWORD(7,2)
mov cx,MAKEWORD(7,2)
mov eax,MAKEWORD(7,2)
push MAKEWORD(7,2)