Hi Everyone,
i have recently started learning assembly and so far i do enjoy it ,
however my recent problem has me stumped ...
The question is : ask the user to enter a keystroke and then determine whether its a decimal # or lower case char or printable symbol, or a control key that he or she has entered.
Now so far im able to ask the user to enter a key and then i can output to the screen what he enter but i can seem to determine how to show what he entered, i have a feeling i'll need to use the case statement ,,,, Any help would be appreciated.
Code:
; This program displays a prompt for the user to enter a keystroke
segment .data ; initialized data segment
msg db "Please enter a keystroke", 0xA,0xD ; length of message
len equ $ - msg
;-----------------------------------------------
segment .bss ; uninitialized data segment
;-----------------------------------------------
key1 resb 10 ; reserve 10 bytes for id input
;------------------------------------------------
segment .text ; code segment
msg2 db "the keystroke entered is : ", 0xA,0xD ; length of message
len1 equ $ - msg2
global _start ; main function
_start: ; select system call 4
;------------------------------------------------------------------------
mov eax, 4 ; standard output device
mov ebx, 1 ; pointer to message buffer
mov ecx, msg ; number of output bytes bassically in segment.data
mov edx, len ;
int 0x80
;-----------------------------------------------------------------------------
mov eax, 3 ; select system call 3
mov ebx, 0 ; standard input device
mov ecx, key1 ; pointer to input buffer
mov edx, 10 ; number of input bytes
int 0x80 ; invoke selected system call
;-------------------------------------------------------------------------
mov eax, 4 ; standard output device
mov ebx, 1 ; pointer to message buffer
mov ecx, msg2 ; number of output bytes bassically in segment.data
mov edx, len1 ;
int 0x80
;---------------------------------------------------------------------------
mov eax, 4 ; standard output device
mov ebx, 1 ; pointer to message buffer
mov ecx, key1 ; number of output bytes bassically in segment.data
mov edx, len ;
int 0x80
exit:
mov eax, 1 ; select system call 1
xor ebx, ebx ; set default exit code
int 0x80 ; invoke selected system call