I'm stuck with this problem:
I want to compare two char with their to know which one come first in alphabetic order (ascii position). So I do something like this:
LOADBYTEA string,x; it loads in the accumulator A, a byte from the string at ; position x
CPA char2,d ;compare it with the first char enter with keybord input
BRLT less ;if A is lesser than char2, then goto less label
BRGT greater ;if A is greater than char2, then goto greater label
the thing is it always brench to less label, whether I enter : a z
or z a
in keyboard input..
The CPA (compare) function make a substraction of the variable char2 and the accumulator A. If the answer is negative, then it'll brench to less. So if a enter z a
, it should be 7A-61=19 and should brench to greater but doesn't!
a z
brench to less like it should. It's like the answer is always negative I don't know why...
Thanks for help!
chari char,d
chari EOL,d
chari char2,d
ldbytea char,d
cpa char2,d
brlt less
brgt gt
less:charo '1',i
stop
gt:charo '2',i
stop
char:.block 1
char2:.block 1
EOL:.block 1 ;the \n
.end