Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

24 bit Binary to ASCII

Status
Not open for further replies.

Wond3rboy

Member
Hi, i was working on a 16x8 multiplication routine. Got it done but now i gotta convert the 24 bit result in to ASCII. I am doing ASM in the PIC18 this time. Any ideas? The fact that the numberbroken(as explained below):

Location
0x50 Low order Byte
0x51 High order Byte
0x52 Upper order Byte

It wont work with the simple ASCII routine :(

Any pointers?
 
hi,
This may help.

Code:
;place to suit your program
ASCBFR0     EQU 0X58;msb 8*ascii oup bfr
ASCBFR1     EQU 0X59
ASCBFR2     EQU 0X5A
ASCBFR3     EQU 0X5B
ASCBFR4     EQU 0X5C
ASCBFR5     EQU 0X5D
ASCBFR6     EQU 0X5E
ASCBFR7     EQU 0X5F

;enter with 3 bytes in
B2AVH         EQU 0X30;bin2asc
B2AVM         EQU 0X31;bin2asc
B2AVL        EQU 0X32;bin2asc

;convert 32bit bin to 8 asci in ASCBFR0
;can be modified for 8 characters.
BIN2ASC:
        CLRF    ASCBFR0
        CLRF    ASCBFR1
        CLRF    ASCBFR2
        CLRF      ASCBFR3
        CLRF      ASCBFR4
    CLRF    ASCBFR5
    CLRF      ASCBFR6
    CLRF    ASCBFR7
          
        MOVLW   0X24 ;bits
    MOVWF   TEMP1

BITLP:;shift msb into carry
        RLF     OP1L,F;B2AVL,F
        RLF     OP1M,F;B2AVM,F
    RLF     OP1H,F;B2AVH,F
     
        MOVLW   ASCBFR7;0=msd 1st
        MOVWF   FSR;fsr=pointer to digits
        MOVLW   0X8;digits to do
        MOVWF   TEMP2
ADJLP:
        RLF     INDF,F;shift digit 1 bit left
        MOVLW   0X0A
        SUBWF   INDF,W;check and adjust for decimal overflow
        BTFSC STATUS,C
        MOVWF   INDF

        DECF    FSR,F;incf=msd 1st next digit
        DECFSZ  TEMP2,F
        GOTO    ADJLP
        DECFSZ  TEMP1,F;next bit
        GOTO    BITLP

        MOVLW 0X30;make asci
        IORWF ASCBFR0,F
        IORWF ASCBFR1,F
        IORWF ASCBFR2,F
        IORWF ASCBFR3,F
        IORWF ASCBFR4,F
    IORWF ASCBFR5,F
    IORWF ASCBFR6,F
    IORWF ASCBFR7,F

        RETURN
 
Status
Not open for further replies.

Latest threads

Back
Top