That really depends on if you want the hex value or a string representation:
This one gets the text value that can be converted to a byte (if necessary);
Pardon the weird labels.
; Compiled with A86 (http://eji.com/a86/)
; This program shows how to get user input with echo.
ORG 100H
mov ah, 09h
mov dx, askName;
int 21h ; Ask for year
mov cx, 0ah
mov si, userInput; ; Place to store the user name
getName:
mov ah, 01h
int 21h ; Get input with echo
cmp al, 0dh ;
je printQuit ; Quit if Carriage-return
mov [si], al ; Put entered char in user name
cmp byte ptr [finalStop], 24h; is 4th dollar-sign gone?
jne printQuit ; if so, buffer is full?, quit
inc si ; move the position
loop getName; ; Keep going (looping)
printQuit:
mov ah, 09h
mov dx, youEntered;
int 21h ; Print the finished input
mov dx, lastDigsLabel;
int 21h
mov dx, userInput+2;
int 21h
quit:
int 20h ; *** DROP TO DOS ***
askName: db 'Enter a 4-digit year and press enter: $'
youEntered: db 'You entered', 0dh, 0ah
userInput: db '$$$'
finalStop: db '$$'
lastDigsLabel: db 0dh, 0ah, 'Last two digits are: $'
thines01
Postaholic
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402