Fasm c-compatible syntax typedef macro

Source: Internet
Author: User

When porting the C header file, the Assembly always finds that the db dw dd DQ type is hard and unreadable, And the Win32 and win64 structures need to be maintained in two copies. So I wrote a FASM typedef macro (the same as C), which can be used in struct definition, data definition, and local variable definition of the function.

 

; --- ===--- FASM typedef macro by G-spider @ 2013; --- ===--- macro @ typedef base, [type] {forward struc type [v] \{\ common match any, V \\{. base v \\} match, V \\{. base? \\}\} Macro type [v] \{\ common match any, V \\{ base v \\} match, V \\{ base? \\}\} Virtual at 0 base? Sizeof. # type = $ end virtual} macro typedef [statement] {common match GS @ base GS @ type, statement \ {macro @ typedef GS @ base, GS @ Type \} For example:; declare typedef dd sdwordtypedef sdword DWORD, int32, longtypedef dB char, byte_win64 equ falsematch = true, _ win64 {typedef pvoid} match = false, _ win64 {typedef dd pvoid} typedef pvoid handle, pstr, pwstr ;....................; structure Definition struc point X, Y {. :. X sdword X. Y int 32 Y. size = $-.} struct size CX long? Cy long? Ends ;....................; data Definition M1 sdword 12, 13, 14, sizeof. dwordm2 int32 12, 13, 14, sizeof. int32my point 7, my. sizeint 32m3 int32 ;....................; function Local data definition proc windowproc uses ebx esi edi, hwnd, wmsg, wparam, lparam local HDC: handle local mysize: Size

Note:

Version 1.70 (Apr 17,201 2 ):
[+] Macroinstruction argument now can have default value, defined with "="
Symbol followed by value after the argument name in definition.

Therefore, for analyticdb 1.7 and later versions, it can be abbreviated:

 
Macro typedef [Statement *] {common match GS @ base GS @ type, statement \ {IRP type, GS @ Type \\{ struc type [V =?] \\{\\\ Common. Gs @ base v \\\} macro type [V =?] \\{\\\ Common GS @ base v \\\} virtual at 0 Gs @ base? Sizeof. \\# type = $ end virtual \\}\}}

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.