Ross Myers

HC08 16bit Subtraction

Discussion created by Ross Myers on Dec 2, 2007
Latest reply on Dec 3, 2007 by David Payne
Hi all,
 
Can anybody please provide post some assembler code to subtract an IMM 16bit value from a 16bit value in RAM. Given that the SUB #xx command is limited to an 8bit immediate value I'm not sure how to do this.
Is it a matter of using say the SP and H,X to perform the operation?
 
I need to be able to handle two possibilites:
 
RAM Var = $8000
IMM Val = $2000
$8000 - $2000 = $6000
 
The another scenario is where the RAM value is less than the IMM value...
 
RAM Var = $2000
IMM Val = $3000
$2000 - $3000 = $F000
 
Thanks,
Ross

Outcomes