Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; params: addr_l - address of low byte of 16 bit value
- ; addr_h - address of high byte of 16 bit value
- ; val - literal to add
- ; x reg - assumes x is index into addresses
- ; note: stomps A register
- .macro add16x8const addr_l, addr_h, val
- clc
- lda addr_l,x
- adc val
- sta addr_l,x
- bcc :+
- inc addr_h,x
- :
- .endmacro
- ; params: addr_left_l/h - address of low/high byte that is being changing
- ; addr_right_l/h - address of the low/high byte being added to l-value.
- ; x reg - assumes x is index into addresses
- ; note: stomps A register
- .macro add16x16 addr_left_l, addr_left_h, addr_right_l, addr_right_h
- ; low byte
- clc
- lda addr_left_l,x
- adc addr_right_l,x
- sta addr_left_l,x
- ; high byte
- lda addr_left_h,x
- adc addr_right_h,x
- sta addr_left_h,x
- .endmacro
- ; params: addr_left_l/h/hh - address of low/high/xtrahigh byte that is being changing
- ; addr_right_l/h - address of the low/high byte being added to l-value.
- ; x reg - assumes x is index into addresses
- ; note: stomps A register
- .macro add24x16 addr_left_l, addr_left_h, addr_left_hh, addr_right_l, addr_right_h
- ; low byte
- clc
- lda addr_left_l,x
- adc addr_right_l,x
- sta addr_left_l,x
- ; high byte
- lda addr_left_h,x
- adc addr_right_h,x
- sta addr_left_h,x
- ; extra high byte
- bcc :+
- inc addr_left_hh,x
- :
- .endmacro
- ; Adds an signed 16 bit number to an unsigned 24 bit number
- ; params: addr_left_l/h/hh - address of low/high/xtrahigh byte that is being changing
- ; addr_right_l/h - address of the low/high byte being added to l-value.
- ; x reg - assumes x is index into addresses
- ; note: stomps A register
- .macro add24xs16 addr_left_l, addr_left_h, addr_left_hh, addr_right_l, addr_right_h
- clc
- lda addr_right_l,x
- adc addr_left_l,x
- sta addr_left_l,x
- lda addr_right_h,x
- bpl :+
- dec addr_left_hh,x ; adjust if r-value is negative
- :
- adc addr_left_h,x
- sta addr_left_h,x
- bcc :+
- inc addr_left_hh,x ; adjust hh if carry
- :
- .endmacro
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement