Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


8051 BCD instructions

  • José A. Ruiz
    José A. Ruiz


    A question for the developers:

    Does SDCC for 8051 ever use any of the BCD instructions (DA and XCHD)? Are they used in the libraries?

    Thank you!

  • Maarten Brock
    Maarten Brock

    DA A is used in printf_fast and printf_tiny. But it is never generated by SDCC.
    XCHD is never used nor generated.

    I am curious why you ask this.

  • Sergey

    I'm may be wrong, but I remember, what xchd instruction used as part of fixed-shift (like a >>= 3; ) realization by compiler.

  • José A. Ruiz
    José A. Ruiz

    I ask because the BCD opcode implementation is optional in some FPGA 8051 cores; leaving them out saves a few percentage points of area.

    If the opcodes are used in some library functions, I guess I can profile my application code to make sure they're not used before turning off their implementation. Though I think it's easier and safer to just implement them unconditionally.

    Thank you for the information.