How do I create a macro where you can leave out a parameter? When left out it should remove a piece of code.
CodePudding user response:
From https://sourceware.org/binutils/docs/as/If.html we can use .ifnb
"if not blank"
.macro mymacro arg1, arg2
li a0, arg1
.ifnb arg2
li a1, arg2
.endif
call my_fun
.endm
mymacro 0xdead, 0xbeef // will include li a1, arg2
mymacro 0xdead // will not include li a1, arg2