Archived

This topic is now archived and is closed to further replies.

asm question

This topic is 6558 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

been reading this assembly book for awhile and came up with a question. here goes

The user types one of teh digits 1,2 or 3 and the corresponding message in:

1 - HELLO
2 - GOODBYE
3 - HAVE A NICE DAY

is displayed followed by a new line, and then the sequence of events is repeated. Thus if the user types 1,3,2 the resulting display should be:

1HELLO
3HAVE A NICE DAY
2GOODBYE

thx in advance

Share this post


Link to post
Share on other sites
Yes, looks like he really wants the code for that. (sorry for repeating what you just said, Gromit)
Just don't ask for help every time you encounter a problem. Try to learn while searching for the best way of doing something. Use your brain to ASSEMBLE the pieces of information provided in the book to one big picture. And be a bit clearer if you ask questions. It might be that if you asked your question more exactly, you wouldn't have received this reply of mine.

Share this post


Link to post
Share on other sites
You''re right with jz and sub. After int 21h, the ASCII code of the character is in ah, so:

cmp ah,0x31 ;(0x31=ASCII code of ''1'')
jz label_key1
cmp ah,0x32
jz label_key2
cmp ah,0x33
jz label_key3

(cmp sets the flags like sub does, but doesn''t change the first operand)
Hope this helps you...

Share this post


Link to post
Share on other sites