For fast writing code. I create macro basic fasmw 1.73.
macro _nxt r,lb, rest=0{ dec r
jnz lb
If rest >0
restore lb
end if
}
macro _nxtp r,lb, rest=0{pop r
dec r
jnz lb
If rest >0
restore lb
end if
}
macro mBasic [args] { common
macro mGetArg af*,base*,[arg] \{ \common
;match any,GetBufr \\{ define GetBufr any+af
mov base,[GetBufr+af]
GetReg equ base
;\\}
\forward match =+ x, arg \\{ add base, x \\}
match =- x, arg \\{ sub base, x \\}
;match =:=~ x, arg \\{ shl base, x \\}
match "(", arg \\{ push base \\}
match ")", arg \\{ pop base \\}
match "{(", arg \\{ local .lb
.lb: push base
get_lb equ .lb
display "{"
\\}
match ")}", arg \\{ pop base
dec base
;test base, base
jnz get_lb
restore get_lb
display "}"
\\}
match "{", arg \\{ local .lb
.lb:
get_lb equ .lb
display "{"
\\}
match "}", arg \\{ test base, base
jnz get_lb
restore get_lb
display "}"
\\}
match "vec4" x, arg \\{ irpEqsVec4 equ x
x\\#\\_type equ 'vec4'
;display x_type
\\}
match "ivec" x, arg \\{ irpEqsIVec equ x
x\\#\\_type equ 'int'
;display x_type
\\}
match ">" x, arg \\{ display '>'
shr base, x \\}
match "<" x, arg \\{ shl base, x \\}
match ":" x, arg \\{ x: x\\#\\_type equ 'label' \\}
match "!0": x, arg \\{ test base, base
jz x \\}
match "!0", arg \\{ test base, base
jz @f \\}
match "!>0": x, arg \\{ test base, base
jnz x \\}
match "to", arg \\{ ;display 'to;'
mov [GetBufr+af],base \\}
match "to": x, arg \\{ ;display 'to2;'
mov x,base \\}
match #:x , arg \\{ x equ base \\}
match : , arg \\{ mov base, [base] \\}
match '(do)' , arg \\{ push base
call base
pop base
\\}
match '(do)': x, arg \\{ push base
call dword x
pop base
\\}
match 'do' , arg \\{ call base \\}
match 'do': x, arg \\{ call dword x \\}
match 'ptR'x:z, arg \\{ mov x,[z]
add z,GetptrR
\\}
match 'ptW'x:z, arg \\{ mov [z],x
add z,GetptrW
\\}
match 'ptR_'x:z, arg \\{ mov x,[z] \\}
match 'ptW_'x:z, arg \\{ mov [z],x \\}
match =* x , arg \\{ x base \\}
\}
if ~ args eq
forward mGetArg args
common end if
purge mGetArg
@@:
}
macro mBasic_ [args] { common
macro mGetArg base*,[arg] \{ \common
;match any,GetBufr \\{ define GetBufr any+af
;mov base,[GetBufr+af]
GetReg equ base
;\\}
\forward match =+ x, arg \\{ add base, x \\}
match =- x, arg \\{ sub base, x \\}
;match =:=~ x, arg \\{ shl base, x \\}
match "(", arg \\{ push base \\}
match ")", arg \\{ pop base \\}
match "{(", arg \\{ local .lb
.lb: push base
get_lb equ .lb
display "{"
\\}
match ")}", arg \\{ pop base
dec base
;test base, base
jnz get_lb
restore get_lb
display "}"
\\}
match "{", arg \\{ local .lb
.lb:
get_lb equ .lb
display "{"
\\}
match "}", arg \\{ test base, base
jnz get_lb
restore get_lb
display "}"
\\}
match "vec4" x, arg \\{ irpEqsVec4 equ x
x\\#\\_type equ 'vec4'
;display x_type
\\}
match "ivec" x, arg \\{ irpEqsIVec equ x
x\\#\\_type equ 'int'
;display x_type
\\}
match ">" x, arg \\{ display '>'
shr base, x \\}
match "<" x, arg \\{ shl base, x \\}
match ":" x, arg \\{ x: x\\#\\_type equ 'label' \\}
match "!0": x, arg \\{ test base, base
jz x \\}
match "!0", arg \\{ test base, base
jz @f \\}
match "!>0": x, arg \\{ test base, base
jnz x \\}
match "to", arg \\{ ;display 'to;'
mov [GetBufr],base \\}
match "to": x, arg \\{ ;display 'to2;'
mov x,base \\}
match #:x , arg \\{ x equ base \\}
match : , arg \\{ mov base, [base] \\}
match '(do)' , arg \\{ push base
call base
pop base
\\}
match '(do)': x, arg \\{ push base
call dword x
pop base
\\}
match 'do' , arg \\{ call base \\}
match 'do': x, arg \\{ call dword x \\}
match 'ptR'x:z, arg \\{ mov x,[z]
add z,GetptrR
\\}
match 'ptW'x:z, arg \\{ mov [z],x
add z,GetptrW
\\}
match 'ptR_'x:z, arg \\{ mov x,[z] \\}
match 'ptW_'x:z, arg \\{ mov [z],x \\}
match =* x , arg \\{ x base \\}
\}
if ~ args eq
forward mGetArg args
common end if
purge mGetArg
@@:
}