Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

beginner question - displaying hex equivalent to ascii character

Status
Not open for further replies.

dsquared

Programmer
Apr 16, 2001
1
0
0
US
I'm a beginner at assembly language. I need to be able to retrieve a character (A-F) from the keyboard and display it's hex equivalent. Any help would be appreciated.

Thank you
Dee Dee
 
You could put what user specifies into a string variable.

MOV SI,offset UserString
LODSB
XOR AX,AX
PUSH 10H
POP CX
IDIV CX
PUSH DX
MOV DX,AX
CMP DX,9
JA @LETTER
ADD DX,30
JMP @DONE
@LETTER :
ADD DX,37
@DONE :
MOV AH,1
INT 21H

POP DX
CMP DX,9
JA @LETTER_
ADD DX,30
JMP @DONE_
@LETTER_ :
ADD DX,37
@DONE_ :
MOV AH,1
INT 21H


Best Regards,

aphrodita@mail.krovatka.ru {uiuc rules}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top