Skip to main content
Visitor II
March 29, 2014
Question

About STM8 decimal adjust

  • March 29, 2014
  • 2 replies
  • 709 views
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?

    This topic has been closed for replies.

    2 replies

    Visitor II
    March 30, 2014
    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

    yscAuthor
    Visitor II
    March 30, 2014
    Posted on March 30, 2014 at 14:25

    Thanks for your

    reply

    , it seems that

    the only

    way to go.