Basically I have to write a program where the user keeps inputting a single character which we evaluate to being decimal, control key, upper case, lower case, symbols etc.
So Looking around I've found some code but it doesn't work. What I am trying to do is taking an ASCII character, and hopefully comparing its HEX value with either 30h or 39h (0 or 9), if its less than 30h than its Something(tm) if its Greater Than 9 It is Something Else(tm), if neither than its clearly a decimal and I can output a message saying so.
However it doesn't seem to work.
segment .data
msg db 'Enter a character: ', 0xA ; text message
len equ $-msg ; length of msg
msg2 db 'Your character is: ' ; text message
len2 equ $-msg2
smallerKey: db "Smaller", 10
smallerLen: equ $-smallerKey
biggerKey: db "Bigger", 10
biggerLen: equ $-biggerKey
segment .bss
;
aChar resb 2 ; reserve 10 bytes for aChar
segment .text
global _start
_start:
; ### Code for Outputting a simple Message ###
mov eax, 4 ; select kernal call #4
mov ebx, 1 ; default output device
mov ecx, msg ; second argument; pointer to message
mov edx, len ; third argument: length
int 0x80 ; invoke kernal call to write
mov eax, 3 ; select kernal call #3
mov ebx, 0 ; default input device
mov ecx, aChar ; pointer to aChar'
int 0x80 ; invoke kernal call to read
decimal:
mov ebx, 30h ; smallest decimal ASCII
mov edx, aChar
cmp edx, ebx
jl smaller
mov ebx, 39h ; smallest decimal ASCII
mov edx, aChar
cmp edx, ebx
jg bigger
jmp exit
smaller: ; Tell that it's a printable symbol
mov eax, 4
mov ebx, 1
mov ecx, smallerKey
mov edx, smallerLen
int 0x80
bigger: ; Tell that it's a printable symbol
mov eax, 4
mov ebx, 1
mov ecx, biggerKey
mov edx, biggerLen
int 0x80
exit:
mov eax, 1
xor ebx, ebx
int 0x80
Here's my code broken down as simple of possible for testing purposes. The code keeps on evaluating that '5' is bigger than 39h and keeps jumping to the "is bigger" label.
I assume its correct that they are evaluating each other as HEX, otherwise I would get an invalid opcode/operant error right? So *what* is '5' showing up as? I'm completely lost without an IDE, which are neither non existent or don't work on modern computers.