; assign immediate to a variable: wb my_var := #23 ; copy variable value to another: wb my_var := my_other_var ; write to memory: wb $2007 := #20 ; write word: ww score := #$1234 ; copy word sized variable: ww highscore := score ; assign value of register example ( a x or y) wb p1score := #0 wb p2score := a wb highscore := aCode here: (updated..x1)
.macro findequal exp
.if .xmatch(.mid(_equalpos_,1,exp),:=)
.exitmacro
.else
_equalpos_ .set _equalpos_ + 1
.if (_equalpos_ >= .tcount(exp))
.exitmacro
.endif
findequal exp
.endif
.endmacro
.macro wb exp
_equalpos_ .set 1 ; first check at token 1
findequal exp
.if (_equalpos_ >= .tcount(exp))
.error "No assignment in poke macro"
.exitmacro
.endif
.if .xmatch(.mid((_equalpos_+1), .tcount({exp}) - _equalpos_ - 1 , {exp}),x) ; assign reg x
stx .mid(0,_equalpos_,{exp})
.elseif .xmatch(.mid((_equalpos_+1), .tcount({exp}) - _equalpos_ - 1 , {exp}),y) ; assign reg y
sty .mid(0,_equalpos_,{exp})
.elseif .xmatch(.mid((_equalpos_+1), .tcount({exp}) - _equalpos_ - 1 , {exp}),a) ; assign reg a
sta .mid(0,_equalpos_,{exp})
.else
lda .mid((_equalpos_+1), .tcount({exp}) - _equalpos_ - 1 , {exp})
sta .mid(0,_equalpos_,{exp})
.endif
.endmacro
.macro ww exp
_equalpos_ .set 1 ; first check at token 1
findequal exp
.if (_equalpos_ >= .tcount(exp))
.error "No assignment in poke macro"
.exitmacro
.endif
.if .xmatch(.mid((_equalpos_+1),1, {exp}), #) ; immeidate mode
lda #<(.mid((_equalpos_+2), .tcount({exp}) - _equalpos_ - 2 , {exp}))
sta .mid(0,_equalpos_,{exp})
.if (>(.mid((_equalpos_+2), .tcount({exp}) - _equalpos_ - 2 , {exp}))) <> (<(.mid((_equalpos_+2), .tcount({exp}) - _equalpos_ - 2 , {exp}))) ; high byte not equal to low byte
lda #>(.mid((_equalpos_+2), .tcount({exp}) - _equalpos_ - 2 , {exp}))
.endif
sta .mid(0,_equalpos_,{exp}) + 1
.else
lda .mid((_equalpos_+1), .tcount({exp}) - _equalpos_ - 1 , {exp})
sta .mid(0,_equalpos_,{exp})
lda .mid((_equalpos_+1), .tcount({exp}) - _equalpos_ - 1 , {exp})+1
sta .mid(0,_equalpos_,{exp}) + 1
.endif
.endmacro
No comments:
Post a Comment