Skip to main content
Visitor II
April 30, 2013
Question

bcd to bin

  • April 30, 2013
  • 2 replies
  • 623 views
Posted on April 30, 2013 at 09:19

hello,

please can help me someone one with an assembly language  who convert a 5digit BCD to BIN

many thanks

    This topic has been closed for replies.

    2 replies

    Visitor II
    April 30, 2013
    Posted on April 30, 2013 at 15:45

    .ScanU16
    ; Save ASCII Input
    PUSHW Y
    PUSHW X
    ; U16 Result = 0;
    CLRW X
    ; Loop counter initialization
    LDW Y,#5
    ScanU16Loop
    ; Result = Result * 10;
    SLLW X
    ; Temporary word allocation
    PUSHW X
    SLLW X
    SLLW X
    ADDW X,(1,SP)
    ; (1,SP) = value of A
    CP A,#'0'
    JRMI BadDigitValue
    CP A,#'9'
    JRUGT BadDigitValue
    SUB A,#'0'
    LD (2,SP),A
    CLR (1,SP) ; High Byte is always 0
    ; Result = Result + Value_of_Digit;
    ADDW X,(1,SP)
    BadDigitValue
    ; Temporary word deallocation
    ADDW SP,#2
    ; Process next digit
    POP A
    DECW Y
    JRNE ScanU16Loop
    SUBW SP,#1
    RET

    Marc, the above function returns in X the value of the five ASCII digits which are stored in {A,X,Y}. This function is the inverse of the one I send you here

    /f57b93c7

    EtaPhi
    Visitor II
    May 2, 2013
    Posted on May 02, 2013 at 21:12

    hello sir,

    i thank you very mutch for the program you have prepared.

    it works very well

    i like too the stm8s ,pity there is not many information on it

    but any way, thanks for the help

    marc debruyne