cancel
Showing results for 
Search instead for 
Did you mean: 

About STM8 decimal adjust

ysc
Associate
Posted on March 29, 2014 at 12:02

Hello everyone, I just started learning STM8 assembly language, but can not find the decimal adjust instruction, so do not BCD arithmetic.

Have thought about writing a decimal adjustment subroutine, the addition should be able to overcome, but subtraction instruction (SUB SBC) does not affect the H flag, so after BCD subtraction does not know how to adjust.

May I ask how to properly use assembly language do BCD addition and subtraction?

2 REPLIES 2
fggnrc2
Associate II
Posted on March 30, 2014 at 13:31

Hi,

I usually code a BCD subtraction as a sum of the ten's complement of the subtrahend.

Please, see

http://en.wikipedia.org/wiki/Binary-coded_decimal

Regards,

EtaPhi

ysc
Associate
Posted on March 30, 2014 at 14:25

Thanks for your

reply

, it seems that

the only

way to go.