Re: branch computation

From: smf <smf_at_null.net>
Date: Mon, 14 Oct 2019 11:40:09 +0100
Message-ID: <38689671-8c7a-aa64-f7f3-aef6bbe548ca_at_null.net>
If you have some spare ram then you can simplify that.

sec
lda target
sbc current
sta result
lda target+1
sbc current+1
eor result
bmi out_of_range
lda result
...
out_of_range:

Assuming variables in zero page that is 17 bytes, 25 cycles (23 if out
of range). If none are in zero page then it's 24 bytes, 32 cycles (29 if
out of range)

compared to

25 bytes, 25 cycles for a forward branch, 21 for forward branch out of
range, 27 for backwards branch, 24 for backwards branch out of range.
With 4 extra bytes & 4 cycles if not in zero page.

It depends on ram/register usage as to which one makes more sense, as
you may not have any zero page and you may need to store/restore the X
register to ram/stack which will add more bytes and cycles.
Received on 2020-05-29 23:06:32

Archive generated by hypermail 2.3.0.