Re: branch computation

From: Chriz <chris_at_lachriz.de>
Date: Mon, 21 Oct 2019 20:29:11 +0200
Message-Id: <64D27085-0E0C-4D7D-A2F3-F5B5789AF37C_at_lachriz.de>
> Am 20.10.2019 um 22:00 schrieb Chriz <chris_at_lachriz.de>:
> 
> 
>> Am 13.10.2019 um 22:13 schrieb didier_at_aida.org:
>> 
>> thanks, it works perfectly
> 
> I came up with a shorter version of the range check. The idea is to add $80 before checking just the high byte for zero.
> 
>> sec
>> lda target
>> sbc current
>> tax
>> lda target+1
>> sbc current+1
> cpx #$80  ; bit 7 of x reg -> carry
> adc #0
> bne out_of_range
> ; offset is in x

I found another code variant which uses the accumulator only:

sec
lda target
sbc current
sta offset ; where you need it
rol
and #1
adc target+1
clc
sbc current+1
bne out_of_range

Chriz
Received on 2020-05-29 23:17:11

Archive generated by hypermail 2.3.0.