Code: Select all
if {carry set}
; do code
endif
;or
if {equal}
; blah blah
endif
if {less}
; blah blah
endif
Moderator: Moderators
Code: Select all
if {carry set}
; do code
endif
;or
if {equal}
; blah blah
endif
if {less}
; blah blah
endif
The macro would actually change carry set to BCC and equal to BNE since I want to enter the block of code if the flag is set.Hamtaro126 wrote:
IF Carry Set = BCS
IF Equal = BEQ
IF Less = BMI(?)
Which is OK if you're dealing with signed numbers. The carry flag can be used for unsigned comparisons, while N and V should be used for signed numbers.Movax12 wrote:NESHLA used the N flag >:(
Code: Select all
; carry set
; carry clear
; no carry
; not carry
; C
; not C
; C set
; C clear
; less
; not less
; greater_equal
; not greater_equal
; zero
; zero clear
; zero set
; not zero
; equal
; not equal
; Z
; not Z
; Z set
; Z clear
; plus
; not plus
; positive
; not positive
; minus
; negative
; not minus
; not negative
; N
; not N
; N set
; N clear
; bit7
; bit7 set
; bit7 clear
; not bit7
; V
; overflow
; overflow set
; overflow clear
; not overflow
; V
; V set
; V clear
; not V
; bit6
; bit6 clear
; bit6 set
; not bit6
Is there a standard test on 6502 for whether unsigned + signed (e.g. position + change) has overflowed unsigned?tokumaru wrote:The carry flag can be used for unsigned comparisons, while N and V should be used for signed numbers.
Not hard at all. It also wouldn't be hard to implement do-while loops, or repeat-until.tepples wrote: Would it be hard to make macros for greater, not greater, less_equal, not less_equal, that use a branch on Z that jumps over a branch on C?
I briefly thought about that, it might not be too hard.. I'll think about it.Would "else" be hard?
Code: Select all
.macro process_expression_FLAGS flagtest, flag, flagisset
; Find a value for which flag we are checking and return:
_n_ .set ( (.xmatch(.left(1, {flagtest}) , no)) .or (.xmatch(.left(1, {flagtest}) , not)) ) ; not or no prefix
flag .set (.xmatch(.mid(_n_,1, {flagtest}) , C)) * 1 + (.xmatch(.mid(_n_,1, {flagtest}) , Z)) * 2 + (.xmatch(.mid(_n_,1,{flagtest}) , N)) * 3 + (.xmatch(.mid(_n_,1,{flagtest}) , V)) * 4 + (.xmatch(.mid(_n_,1,{flagtest}) , G)) * 5
flag_set_default .set (.xmatch(.mid(_n_+1,1, {flagtest}), set)) * 1 + (.xmatch(.mid(_n_+1,1, {flagtest}), clear)) * -1
.ifnblank .mid(_n_+2,1, {flagtest}) ; user added clear or set, also accept 'do' from "while <exp> do" syntax
invert_flag .set .xmatch(.mid(_n_+2,1, {flagtest}), clear) * -1 + .xmatch(.mid(_n_+2,1, {flagtest}), set) * 1 + .xmatch(.mid(_n_+2,1, {flagtest}), do) * 1
.else
invert_flag .set 1 ; no clear or set added, that's okay make it a 1
.endif
invert_flag .set invert_flag * (_n_ * -2 + 1)
.if ( (flag = 0) .or (flag_set_default = 0) .or (invert_flag =0))
.error "Unknow expression in flag test."
.fatal ""
.endif
flagisset .set ((flag_set_default * invert_flag) > 0) ; This will always result in a negative or positive, positive being flag is being tested for
.endmacro
Code: Select all
cmp #JOY_A
if equal
jmp @Freeze
endif
cmp #JOY_B
if equal
jmp @Melt
endif
lda #0
rts
As far as I know, it's not possible. The macros need to generate labels, and they'll always mess with the local (@) labels. I thought it might be possible to fix this by generating the label inside a scope, but looks like the @ labels don't care about scopes, so they'll get invalidated when any normal label comes. Then I thought it might be possible to generate the label using "foo = *" or "foo := *", but that also invalidates the local labels. As does "foo .set 123". That's all the possible workarounds I can think of...Bananmos wrote:Do you think it would be possible to make your macro package support this?...