Not doing something to the outcome of both sub
‘s relies on the byte wraparound and can only works as long as unsigned logic is used via jbe
and friends.
This is the simplest code you can write to differentiate between any case letters and all the rest:
sub al, 'A'
cmp al, 'Z'-'A'
jbe Letter ;It's uppercase
sub al, 'a'-'A'
cmp al, 'z'-'a'
jbe Letter ;It's lowercase
NonLetter:
...
Letter:
...
Note that your 2nd subtraction must not use ‘a’ (=97) because the 1st subtraction already subtracted ‘A’ (=65). Thus here only the complementary value is needed. 97 – 65 = 32
2
solved How to trace my assembly language program?