Skip to content

Commit

Permalink
added sbc16 macro for immediate number
Browse files Browse the repository at this point in the history
  • Loading branch information
nealvis committed Jan 7, 2022
1 parent 385cd46 commit 29727af
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions nv_math16_macs.asm
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,36 @@ Done:
//
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
// inline mcaro to subtract 16 bit immed value from value in memory.
// result_addr = addr1 - num
// full name: nv_sbc16u_mem16u_immed16u
// params:
// addr1: Operand for subtraction.
// num: immediate value for subtraction.
// result_addr: address of word to recieve the result of subtraction.
// Processor Status flags:
// Carry flag will be set if no borrow was required from MSB subtraction
// ie if MSB subtraction was $04 - $01, carry is set
// Carry flag will be clear if borrow was required from MSB subtraction
// (decimal subtraction.) ie $01 - $04 carry is clear
// No other flags are reliably set.
// Accum: changes
// X Reg: No change
// Y Reg: No Change
.macro nv_sbc16_mem_immed(addr1, num, result_addr)
{
sec // set carry for subtraction
lda addr1
sbc #(num & $00FF) // subtract LSBs
sta result_addr // store LSB of result
lda addr1+1
sbc #((num >> 8) & $00FF) // subtract MSBs
sta result_addr+1 // store MSB of result
}
//
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
// macro routine to test if one rectangle overlaps another
Expand Down

0 comments on commit 29727af

Please sign in to comment.