Compare two letters and which comes first

Started by josefalarka, January 25, 2011, 11:14:01 PM

Previous topic - Next topic

josefalarka

Make a program that will ask the user to input two letters, compare them, and display which of the two letters come first based on the alphabet (A to Z).


Gunner

~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

dedndave

 :bg

hiyas Rob
well - if he looks at the code, there is enough info there to accomplish his task   :U

clive

Put your two characters in AL and AH respectively, and compare them.

CMP AL,AH
JZ  thesame
JC  AHbigger

Google for an ASCII character chart, but A is decimal 65, Z is decimal 90. Things get problematic if you have mixed case, in which case you should pick upper or lower and convert to that before the comparison.
It could be a random act of randomness. Those happen a lot as well.

josefalarka

How to use 16-bit linker in masm32? I already have the link16.exe file.  I have use this command,

c:\masm32\link32 compare.asm
Run File [compare.exe] compare
List File [nul.map]: compare
Libraries [.lib]: compare
Definitions File[nul.def]: compare
LINK : fatal error L1092: cannot open module-definition file - compare.def

Is there any way to modify this code in MASM32 32-bit syntax?

clive

It could be a random act of randomness. Those happen a lot as well.

mineiro

If you have uppercase and lowercase characters, do some "and" or "or" with 20h.
A==41h  a==61h
Z==5Ah  z==7ah
regards.

brethren

Quote from: j053f on January 25, 2011, 11:14:01 PM
Make a program that will ask the user to input two letters, compare them, and display which of the two letters come first based on the alphabet (A to Z).

which comes first 'a' or 'Z' :P even in small programs it pays to think about boundary cases