 macro
&lab ph4 &parm
 lclc &char
 lclc &char1
 lclc &char2
&lab anop
&char amid &parm,1,1
 aif "&char"="#",.immediate
 aif "&char"="@",.at
 aif s:longa=1,.chk1
 rep #%00100000
.chk1
 aif "&char"<>"{",.chk2
&char amid &parm,l:&parm,1
 aif "&char"<>"}",.error
&parm amid &parm,2,l:&parm-2
 ldy #2
 lda (&parm),y
 pha
 lda (&parm)
 pha
 ago .shorten
.chk2
 aif "&char"<>"[",.absolute
 ldy #2
 lda &parm,y
 pha
 lda &parm
 pha
 ago .shorten
.absolute
 lda &parm+2
 pha
 lda &parm
 pha
 ago .shorten
.at
&char1 amid &parm,2,1
&char2 setc &char1
 ph&char1
 aif l:&parm<3,.chk2a
&char2 amid &parm,3,1
.chk2a
 ph&char2
 ago .shorten
.immediate
&parm amid &parm,2,l:&parm-1
 pea +(&parm)|-16
 pea &parm
 ago .done
.shorten
 aif s:longa=1,.done
 sep #%00100000
.done
 mexit
.error
 mnote "Missing closing '}'",16
 mend
 macro
&lab ErrWriteCString &a1
&lab ph4 &a1
 Tool $210c
 mend
 macro
&lab tool &a1
&lab ldx #&a1
 jsl $e10000
 mend
 macro
&lab ora2 &arg1,&arg2,&dest
&lab anop
 lclc &char
&char amid &arg1,1,1
 aif "&char"="@",.at1
 lda &arg1
 ago .add
.at1
&char amid &arg1,2,1
 aif "&char"="x",.x1
 aif "&char"="X",.x1
 aif "&char"="y",.y1
 aif "&char"="Y",.y1
 ago .add
.x1
 txa
 ago .add
.y1
 tya
.add
 ora &arg2
&char amid &dest,1,1
 aif "&char"="@",.at2
 sta &dest
 ago .b
.at2
&char amid &dest,2,1
 aif "&char"="x",.x2
 aif "&char"="X",.x2
 aif "&char"="y",.y2
 aif "&char"="Y",.y2
 ago .b
.x2
 tax
 ago .b
.y2
 tay
.b
 mend
