I'm using the HC12 chip.
We have instructions SUBA
and DECA
. The way you use SUBA
is by subtracting some value (either in memory or a value you specify) from register A. DECA
however takes no parameters and just subtracts $01 from register A. So my question is what is the difference between the instructions SUBA #01
and DECA
? My guess was that they behaved differently on negative numbers, but I am not entirely sure.
The question I'm dealing with:
LDAA #230 ; 8 bit system, so this number is technically -26 in 2s complement. Register A is 8 bits, with LDAA loading into register A
LOOP: SUBA #01
BGT LOOP
; rest of code
Would the code above work differently if SUBA #01
was replaced with DECA
?
DECA
is a very common operation and thus the ability to encode it in a smaller instruction was deemed worth its redundancy.