RSS Forums RSS
Please support our Assembly advertiser: Programming Forums
Views: 2281 | Replies: 3
Reply
Join Date: Nov 2005
Posts: 2
Reputation: Knight3 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Knight3 Knight3 is offline Offline
Newbie Poster

A simple problem can anyone help

  #1  
Nov 7th, 2005
I'm writing a program in assebly using x86 intel processor series and a flat model



can anyome suggest anything about this?

;;;;;;;;;;;;;;;;;;;


input string,40 ;the user enter a characher 'q' for instance

atod string ; now the value in eax as decimal

;;i need to compare the number and if is 'q' to quit
;;i've tried this senario

cmp eax,'q'
jz quit ;;;;;;not working


cmp al,'q' ;;;;;;not again
jz quit

cmp eax,113 ;;;;where 113 is the decimal ascii value of 'q'
jz quit


cmp al,113 ;;;;;nothing
jz quit


cmp al,71 ;;;i didnt not make the convertion here atod
;;and nothing again 71 is hex of 'q'

cmp eax,113 ;;;;same;;nothing

can anyone help?


Thanks in advance









;;;;;;;;;;;;;;;;;;;
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2005
Location: 55 26'N 118 46'W
Posts: 184
Reputation: Tight_Coder_Ex is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 13
Tight_Coder_Ex's Avatar
Tight_Coder_Ex Tight_Coder_Ex is offline Offline
Junior Poster

Re: A simple problem can anyone help

  #2  
Nov 11th, 2005
What is the underlying operating system, or are you using BIOS calls.

In any event, EAX won't work because especially in the case of ASCII only an 8 bit value is returned and you are comparing a 32 bit value and may not know at any given time what the value of bits 31 - 8 are. Comparing cmp al,'q', should work except where caps lock may be on then you would have to compare against 'Q'. The method I usually use is to implement a case insensitive comparison where I'll convert all characters in AL to upper or lower case.

mov al, [Character]
and al, 0x5f
cmp al,'Q'
jz Done
Reply With Quote  
Join Date: Nov 2005
Posts: 2
Reputation: Knight3 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Knight3 Knight3 is offline Offline
Newbie Poster

Re: A simple problem can anyone help

  #3  
Nov 12th, 2005
Originally Posted by Tight_Coder_Ex
What is the underlying operating system, or are you using BIOS calls.

In any event, EAX won't work because especially in the case of ASCII only an 8 bit value is returned and you are comparing a 32 bit value and may not know at any given time what the value of bits 31 - 8 are. Comparing cmp al,'q', should work except where caps lock may be on then you would have to compare against 'Q'. The method I usually use is to implement a case insensitive comparison where I'll convert all characters in AL to upper or lower case.

mov al, [Character]
and al, 0x5f
cmp al,'Q'
jz Done


Thanks Tight_Coder_Ex

You made it clear to me thanks.Problem solved.
Reply With Quote  
Join Date: Dec 2006
Location: delhi
Posts: 23
Reputation: mytime19 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
mytime19 mytime19 is offline Offline
Newbie Poster

Re: A simple problem can anyone help

  #4  
Dec 22nd, 2006
give me complete program i'll solve it..
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 10:40 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC