Hi,
I've been pulling my hair out for a few days now, and it's time for some professional help. I have to write a short assembly language program that takes one input from the keyboard (any single key), and displays its ascii hex code on the screen. For example, you run the program and it waits for an input from they keyboard. If you type a 0 (zero), it should display 30 on the screen (30 being the ascii hex code for zero). I've come up with several ways to echo the key on the screen, which would be great if that's what I needed to do.
Here's the shortest version of my many incorrect versions:
[code]
code segment
setdisplay:
;set disp mode 02h, erase all pages:
mov ah,00h
mov al,02h
int 10h
;set page 1:
mov ah,05h
mov al,01h
int10h
getkey:
mov ah,00h
int 16h
printkey:
;position the cursor:
mov ah,02h
mov bh,01h
mov dh,0ch
mov dl,
int 10h
;display the key
mov ah,02h
mov dl,al
int 21h
jmp getkey
code ends
[/code]
I also have versions with int 10h instead of 21h, but I get the same results.
I think it has something to do with moving the hex code from AL to memory, then extracting it as a string and printing the two characters one at a time - but I'm really not sure.
Any ideas?
Radarfxst
I've been pulling my hair out for a few days now, and it's time for some professional help. I have to write a short assembly language program that takes one input from the keyboard (any single key), and displays its ascii hex code on the screen. For example, you run the program and it waits for an input from they keyboard. If you type a 0 (zero), it should display 30 on the screen (30 being the ascii hex code for zero). I've come up with several ways to echo the key on the screen, which would be great if that's what I needed to do.
Here's the shortest version of my many incorrect versions:
[code]
code segment
setdisplay:
;set disp mode 02h, erase all pages:
mov ah,00h
mov al,02h
int 10h
;set page 1:
mov ah,05h
mov al,01h
int10h
getkey:
mov ah,00h
int 16h
printkey:
;position the cursor:
mov ah,02h
mov bh,01h
mov dh,0ch
mov dl,
int 10h
;display the key
mov ah,02h
mov dl,al
int 21h
jmp getkey
code ends
[/code]
I also have versions with int 10h instead of 21h, but I get the same results.
I think it has something to do with moving the hex code from AL to memory, then extracting it as a string and printing the two characters one at a time - but I'm really not sure.
Any ideas?
Radarfxst