Which word to bcd subroutine is faster?

Discussion in 'Sega Discussion' started by Scorpion Illuminati, Oct 11, 2016.

Tags:
  1. Scorpion Illuminati

    Scorpion Illuminati Scorpion Illuminati Lead Developer(Site Supporter)

    Joined:
    Oct 1, 2015
    Messages:
    25
    Likes Received:
    1
    Which word to bcd subroutine is faster?
    Code:
    ;D0=binary number (0-9999)
    ;D2=binary number converted to four digit BCD
    
        moveq   #0,d2       ;Clear conversion register.
        moveq   #3,d7       ;Number of BCD digits-1.
    loop2
        divu    #10,d0      ;D0:LOW = D0/10, D0:HIGH = D0%10
        move.l  d0,d1       ;Copy to split quotient and remainder
        and.l   #$FFFF,d0   ;D0:HIGH = 0
        clr.w   d1          ;D1:LOW = 0, D1:HIGH = 0..9
        ror.l   #4,d1       ;Align new digit to the end (div goes backward)
        ror.w   #4,d2       ;Make room to add digit to BCD number
        add.w   d1,d2       ;Add digit to binary number.
        dbra    d7,loop2
    
    or
    Code:
    ;D0=binary number (0-9999)
    ;D2=binary number converted to four digit BCD
    
        moveq   #0,d2       ;Clear conversion register.
        moveq   #3,d7       ;Number of BCD digits-1.
    loop3
        divu    #10,d0      ;D0:LOW = D0/10, D0:HIGH = D0%10
        move.l  d0,d1       ;Copy to split quotient and remainder
        and.l   #$FFFF,d0   ;D0:HIGH = 0
        clr.w   d1          ;D1:LOW = 0, D1:HIGH = 0..9
        add.l   d1,d2       ;Add digit to binary number.
        ror.l   #4,d2       ;Pull it back into 16-bit window
        dbra    d7,loop3
    
    Any assistance in this matter would be greatly appreciated.

    Sincerely,

    Scorpion Illuminati
     
sonicdude10
Draft saved Draft deleted
Insert every image as a...
  1.  0%

Share This Page