Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/16/02 15:03
Read: times


 
#23049 - RE: HexToDec code

Frank, to keep things easier, your code should do something like this (using one byte, for simplicity and you can represent from 0 to 255, ok?):

mov a, 17h
mov b, 100d
div ab ; 17h / 100d ... A gets 0, the ;remainder 17h goes to B

add a, 30h ; now you have 30h = ascii code of ;0

MOV DPTR, #hextodex ; arbitrary position to
; to save each digit
MOVX @DPTR,A ; at hextodec you have 30h
XCH A,B : puts the remainder in A
mov b, 10d
div ab ; 17h / 10d ... A gets 2, the ;remainder 3h goes to B

add a, 30h ; now you have 32h = ascii code of ;2

inc dptr
MOVX @DPTR,A ; at hextodec+1 you have 32h
XCH A,B : puts the remainder in A
add a, 30h ; now you have 33h = ascii code of ;3
inc dptr
MOVX @DPTR,A ; at hextodec+2 you have 33h
;
;now put some routine to start reading at hextodec to present "023" at the display :-)
it's not the best code, but is very didactic.. you can use that metod also to convert a value read from an 8 bits ADC to a display using the proper values for division...

HTH







List of 21 messages in thread
TopicAuthorDate
HexToDec code            01/01/70 00:00      
RE: HexToDec code            01/01/70 00:00      
RE: HexToDec code            01/01/70 00:00      
RE: HexToDec code            01/01/70 00:00      
RE: HexToDec code, Mihasic            01/01/70 00:00      
RE: HexToDec code, Mihasic            01/01/70 00:00      
RE: HexToDec code, Mihasic            01/01/70 00:00      
RE: HexToDec code, Mihasic            01/01/70 00:00      
RE: HexToDec code, Mihasic            01/01/70 00:00      
RE: HexToDec code            01/01/70 00:00      
RE: HexToDec code            01/01/70 00:00      
RE: HexToDec code            01/01/70 00:00      
RE: HexToDec code, Mihasic            01/01/70 00:00      
RE: HexToDec code            01/01/70 00:00      
RE: HexToDec code            01/01/70 00:00      
RE: HexToDec code            01/01/70 00:00      
RE: HexToDec code            01/01/70 00:00      
RE: HexToDec code            01/01/70 00:00      
RE: HexToDec code Charles B            01/01/70 00:00      
RE: HexToDec code            01/01/70 00:00      
RE: HexToDec code            01/01/70 00:00      

Back to Subject List