News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

DEFINE_MACRO

Started by minor28, October 18, 2012, 06:30:52 AM

Previous topic - Next topic

minor28

I am trying to translate DEFINE_GUID.

DEFINE_GUID macro guidName:REQ,data:vararg
    LOCAL guid, count

    count = 0
    guid textequ <{>
    for item, <data>
        count = count + 1
        if count eq 11
            guid catstr guid, <item>
        else
            guid catstr guid, <item>, <,>
        endif

        if count eq 3
            guid catstr guid, <{>
        endif

    endm

    guid catstr guid, <}}>
    exitm @CatStr(<guidName>,< equ >,<guid>)

endm


The result from
%echo DEFINE_GUID(GUID_MAX_POWER_SAVINGS, 0A1841308h, 3541h, 4FABh, 0BCh, 81h, 0F7h, 15h, 56h, 0F2h, 0Bh, 4Ah)
is
{0A1841308h,3541h,4FABh,{0BCh,81h,0F7h,15h,56h,0F2h,0Bh,4Ah}} equ {0A1841308h,3541h,4FABh,{0BCh,81h,0F7h,15h,56h,0F2h,0Bh,4Ah}}

I cannot figure out why this happens


dedndave

why not use the GUID structure ?
        .DATA
GUID_MAX_POWER_SAVINGS GUID <0A1841308h,3541h,4FABh,<0BCh,81h,0F7h,15h,56h,0F2h,0Bh,4Ah>>


look ma, no macro !   :biggrin:

qWord

You problem is probably that GUID_MAX_POWER_SAVINGS is already declared thus it gets expanded in your macro -> test it with IF[N]DEF
MREAL macros - when you need floating point arithmetic while assembling!

minor28

Quote from: qWord on October 18, 2012, 06:53:15 AM
You problem is probably that GUID_MAX_POWER_SAVINGS is already declared thus it gets expanded in your macro -> test it with IF[N]DEF

Yes, that was the problem. Thank you for your help

jj2007

Quote from: qWord on October 18, 2012, 06:53:15 AM
You problem is probably that GUID_MAX_POWER_SAVINGS is already declared thus it gets expanded in your macro -> test it with IF[N]DEF

Nowhere in the Masm32 incs, but you can find it in WinNT.h

Here is a GUID printer, output:
A1841308-3541-4FAB-BC81-F71556F20B4A

Quoteinclude \masm32\MasmBasic\MasmBasic.inc   ; download
.data
GUID_MAX_POWER_SAVINGS GuidFromString(a1841308-3541-4fab-bc81-f71556f20b4a)

   Init

   movups xmm7, GUID_MAX_POWER_SAVINGS   ; load full GUID into xmm reg

   movd ecx, xmm7
   Print Hex$(ecx), "-"   ; print dword #0

   pshufd xmm7, xmm7, 11100101b   ; move dword #1 into lowest pos
   movd ecx, xmm7
   Print Hex$(cx), "-"
   rol ecx, 16
   Print Hex$(cx), "-"

   pshufd xmm7, xmm7, 11100110b   ; move dword #2 into lowest pos
   movd ecx, xmm7
   bswap ecx
   rol ecx, 16
   Print Hex$(cx), "-"
   rol ecx, 16
   Print Hex$(cx)

   pshufd xmm7, xmm7, 11100111b   ; move dword #3 into lowest pos
   movd ecx, xmm7
   bswap ecx
   Inkey Hex$(ecx), " "

   Exit
end start

TouEnMasm


And if you don't want all this:

include translate.inc
include windows.sdk

.data
GUID_MAX_POWER_SAVINGS GUID sGUID_MAX_POWER_SAVINGS
Fa is a musical note to play with CL

minor28