base:signed_8bit_16bit_addition
This is an old revision of the document!
To add a signed 8-bit delta to a 16-bit value, we need to sign-extend the delta to a full 16 bits. We hold the high byte of the delta in .X and set it to $00 or $ff based on its sign:
ldx #$00 ; implied high byte of delta lda delta bpl :+ dex ; high byte becomes $ff to reflect negative delta :clc adc value ; normal 16-bit addition sta value txa adc value+1 sta value+1
White Flame (aka David Holz)
base/signed_8bit_16bit_addition.1429238032.txt.gz · Last modified: 2015-04-17 04:33 by 127.0.0.1