943,163 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Marked Solved
  • Views: 1239
  • Assembly RSS
Nov 5th, 2009
0

C and Assembly Mixed-Mode Hex comparison program

Expand Post »
Hi, I have an assignment where i have to write a C and assembly mixed-mode program.
  1. The c program takes in two characters which stand for two hex characters.
  2. The assembly procedure then passes each character in turn to a C function which determines if the character is a valid ASCII HEX digit (namely 0-F).
  3. If both characters are valid the assembly language procedure then compares the two HEX digits and returns the larger to the main program.
  4. The main C program then prints out the larger digit.

I am unsure how to do no. 2, namely, how to determine if it's a valid ASCII HEX digit or just garbage. Suggestions?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
HypnotiqBIG is offline Offline
3 posts
since Sep 2009
Nov 5th, 2009
0
Re: C and Assembly Mixed-Mode Hex comparison program
Could we see what you have so far?
Reputation Points: 499
Solved Threads: 365
Postaholic
gerard4143 is offline Offline
2,190 posts
since Jan 2008
Nov 6th, 2009
0
Re: C and Assembly Mixed-Mode Hex comparison program
So far I have my C file taking in 2 characters:
Assembly Syntax (Toggle Plain Text)
  1. char char1, char2;
  2. printf ("Enter a character: ");
  3. scanf ("%c", &char1);
  4.  
  5. while (getchar () != '\n')//so that the program doesn't take in the carriage return as input
  6. continue;
  7.  
  8. printf ("Enter another character: ");
  9. scanf ("%c", &char2);
  10.  
  11. while (getchar () != '\n')//so that the program doesn't take in the carriage return as input
  12. continue;

And I'm just not sure how to verify if their HEX or just normal characters (so either 0-9 or A-F). I was thinking I could just do a bunch of if statements comparing each of them (or make a HEX array, and for loop through it comparing along the way), but is there a better way to do this?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
HypnotiqBIG is offline Offline
3 posts
since Sep 2009
Nov 6th, 2009
0
Re: C and Assembly Mixed-Mode Hex comparison program
So far I have my C file taking in 2 characters:
Assembly Syntax (Toggle Plain Text)
  1. char char1, char2;
  2. printf ("Enter a character: ");
  3. scanf ("%c", &char1);
  4.  
  5. while (getchar () != '\n')//so that the program doesn't take in the carriage return as input
  6. continue;
  7.  
  8. printf ("Enter another character: ");
  9. scanf ("%c", &char2);
  10.  
  11. while (getchar () != '\n')//so that the program doesn't take in the carriage return as input
  12. continue;

And I'm just not sure how to verify if their HEX or just normal characters (so either 0-9 or A-F). I was thinking I could just do a bunch of if statements comparing each of them (or make a HEX array, and for loop through it comparing along the way), but is there a better way to do this?
C has a function called isxdigit which checks if the character is 0 -9 or a - f maybe you could use that...
Reputation Points: 499
Solved Threads: 365
Postaholic
gerard4143 is offline Offline
2,190 posts
since Jan 2008
Nov 6th, 2009
0
Re: C and Assembly Mixed-Mode Hex comparison program
That worked perfectly thank you, I'll mark it as solved for now if more problems come up I'll change that
Reputation Points: 10
Solved Threads: 0
Newbie Poster
HypnotiqBIG is offline Offline
3 posts
since Sep 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Assembly Forum Timeline: Noob looking for guidance
Next Thread in Assembly Forum Timeline: Need help in factorial code





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC