I want to write a program to convert the hex to ascii by using mplab.
eg. convert 0xAF to 0x41 and 0x46 (convert number in file register 0x40+i to ascii and save it in 2 file registers- 0x50+2i, 0x50+2i+1, where i= 0,1,2,3,4,.....)
Please HELP! THANKS!
Now, I only know how to convert 0x0? (from 0x40+i to 0x50+i) with this code and how can I change it to satisfy my wants>
CODE as following:
Main: movlw 0x1 ; Initialize array starting from 0x040
movwf 0x40, A
movlw 0x4
movwf 0x41, A
movlw 0xA
movwf 0x42, A
movlw 0xF
movwf 0x43, A
lfsr 0, 0x040
lfsr 1, 0x050
movlw d'4'
movwf COUNT,A
MainLoop: movff POSTINC0, InputConvertHexToASCII
call ConvertHexToASCII
movwf POSTINC1
decfsz COUNT, F, A
bra MainLoop
bra $
ConvertHexToASCII: movlw upper ASCIIList
movwf TBLPTRU
movlw high ASCIIList
movwf TBLPTRH
movlw low ASCIIList
movwf TBLPTRL
movf InputConvertHexToASCII, W, A
addlw 0x01
movwf COUNTSub, A
Loop: tblrd*+
decf COUNTSub, F, A
bnz Loop
movf TABLAT, W ;Result in WREG
return
org 0x000200
ASCIIList db 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46
end
eg. convert 0xAF to 0x41 and 0x46 (convert number in file register 0x40+i to ascii and save it in 2 file registers- 0x50+2i, 0x50+2i+1, where i= 0,1,2,3,4,.....)
Please HELP! THANKS!
Now, I only know how to convert 0x0? (from 0x40+i to 0x50+i) with this code and how can I change it to satisfy my wants>
CODE as following:
Main: movlw 0x1 ; Initialize array starting from 0x040
movwf 0x40, A
movlw 0x4
movwf 0x41, A
movlw 0xA
movwf 0x42, A
movlw 0xF
movwf 0x43, A
lfsr 0, 0x040
lfsr 1, 0x050
movlw d'4'
movwf COUNT,A
MainLoop: movff POSTINC0, InputConvertHexToASCII
call ConvertHexToASCII
movwf POSTINC1
decfsz COUNT, F, A
bra MainLoop
bra $
ConvertHexToASCII: movlw upper ASCIIList
movwf TBLPTRU
movlw high ASCIIList
movwf TBLPTRH
movlw low ASCIIList
movwf TBLPTRL
movf InputConvertHexToASCII, W, A
addlw 0x01
movwf COUNTSub, A
Loop: tblrd*+
decf COUNTSub, F, A
bnz Loop
movf TABLAT, W ;Result in WREG
return
org 0x000200
ASCIIList db 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46
end