8051 BCD instructions

  • José A. Ruiz

    José A. Ruiz - 2012-10-13


    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 - 2012-10-14

    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

    Sergey - 2012-10-14

    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 - 2012-10-16

    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.


Log in to post a comment.