%if 0 NASM macros to work with ported sources 2023 to 2024 by E. C. Masloch, Public Domain %endif ; NASM original macros (comment for fixmem.pl) cpu 8086 uppercase [list -] ; fix trace listing file to not display unknown segment ; These warnings were added in NASM 2.16.02. They are ; useful, as here, to detect undesired relocations. ; Refer to the report that added these warnings [1] ; and the report desiring an "int label" warning [2]. ; ; [1]: https://bugzilla.nasm.us/show_bug.cgi?id=3392571 ; [2]: https://bugzilla.nasm.us/show_bug.cgi?id=3392678 [warning +reloc-abs-byte] [warning +error=reloc-abs-byte] %unimacro segment 1+.nolist %unimacro segment 0-1+.nolist %imacro segment 0-1+.nolist %ifnempty %00 section %00 %1 %else section %1 %endif %endmacro [list +] %unimacro section 1+.nolist %imacro section 1+.nolist %defstr %%string %1 %strlen %%length %%string %assign %%ii 1 %rep %%length %substr %%sub %%string %%ii %deftok %%token %%sub %ifempty %%token %exitrep %else %assign %%ii %%ii + 1 %endif %endrep %substr %%sub %%string 1, %%ii - 1 %deftok %%token %%sub [%?? %1] %xdefine __SECT__ [%?? %%token] %endmacro %imacro labelsize 3.nolist %idefine %1 %3 %endmacro %unimacro group 1+.nolist %unimacro group 1-*.nolist %imacro group 1-*.nolist %ifndef IGNOREGROUP %ifnempty %00 %xdefine %%all %00 %1 %else %xdefine %%all %1 %endif %rep %0 - 1 %rotate 1 %xdefine %%all %%all %1 %endrep [group %%all] %endif %endmacro %imacro EVEN 0.nolist %ifdef DONOBITS align 2, db ? %elifidni __SECT__, [segment _BSS] alignb 2 %elifidni __SECT__, [segment CODE] align 2, nop %elifidni __SECT__, [section CODE] align 2, nop %elifidni __SECT__, [segment BIOCODE] align 2, nop %elifidni __SECT__, [section BIOCODE] align 2, nop %else align 2, db 0 %endif %endmacro %unimacro istruc 1.nolist %unimacro at 1-2+.nolist %unimacro iend 0.nolist %imacro istruc 1.nolist %push %define %$strucname %1 %$strucstart: %endmacro %imacro at 1-2+.nolist %defstr %$member %1 %substr %$member1 %$member 1 %ifidn %$member1, '.' times (%$strucname%1-%$strucname)-($-%$strucstart) db ? %else times (%1-%$strucname)-($-%$strucstart) db ? %endif %2 %endmacro %imacro iend 0.nolist times %{$strucname}_size-($-%$strucstart) db ? %pop %endmacro %imacro LABEL 0-1+.nolist %endmacro %imacro assume 1+ %endmacro %unimacro int 1.nolist %imacro int 1.nolist %ifnum %1 %if %1 == 3 int3 %else int %1 %endif %else int %1 %endif %endmacro %unimacro struc 1-2.nolist 0 %unimacro struc 1.nolist %unimacro endstruc 0.nolist %imacro struc 0-2.nolist ,0 %push STRUCTURE %ifempty %1 %define %$strucname %00 %else %define %$strucname %1 %endif [absolute %2] %$strucname: ; allow definition of `.member' to work sanely %endmacro %imacro endstruc 0.nolist %{$strucname}_size equ ($-%$strucname) %pop __SECT__ %endmacro %imacro ends 0.nolist %ifnempty %00 %ifctx STRUCTURE %{$strucname}_struc_size equ ($-%$strucname) %pop __SECT__ %endif %endif %endmacro %idefine OFFSET %idefine PTR %idefine LT < %idefine GT > %idefine LTE <= %idefine GTE >= %idefine LE <= %idefine GE >= %idefine EQ == %idefine NE != %idefine MOD % %imacro EXTRN 1-*.nolist %push %rep %0 %defstr %$input %1 %strlen %$length %$input %assign %$index 1 %rep %$length %substr %$letter %$input %$index %if %$letter == ':' %exitrep %endif %assign %$index %$index + 1 %endrep %substr %$output %$input 1, %$index - 1 %deftok %$label %$output extern %$label %rotate 1 %endrep %pop %endmacro %idefine PUBLIC global %imacro PROC 0-1.nolist %00: %ifnempty %1 %ifidni %1, NEAR %undef ret %elifidni %1, FAR %idefine ret retf %else %error Unknown keyword to PROC macro %endif %endif %endmacro %imacro ENDP 0.nolist %undef ret %ifidni %00, 0 %endif %endmacro ; Undo nasm -t trickery to use our END macro instead %undef END %imacro END 0-1.nolist %endmacro %imacro wlcalc 1-2.nolist global wlcalc_%1 wlcalc_%1: %2 %endmacro