Write the following two functions that will ultimately be part of your assembler. Save these two functions and their supporting functions in modules lex.c and evl.c respectively after they have been thoroughly tested.
Changes:
1) pszSrc: a 256-element character array zero terminated
2) puMic: upon entry, pszSrc[puMic] is the first character of the sequence; upon exit, puMic (a non-negative integer value) has been incremented so that pszSrc[puMic] is the character after the last character of the number
3) puVal: the integer value of the constant (a non-negative integer value less than 2^16)
If puVal accurately represents the number scanned, set FEvalNum to FALSE; otherwise, set FEvalNum to TRUE if the actual constant would have been greater than 2^16-1. In the latter case, puVal is set to zero.
A constant may be in decimal, octal, binary or hexadecimal notation (see project manual for a description of their representations)
You are to write driver programs (lexdriver & evldriver) and make sure that these two routines work correctly for all sets of data.
The header for FGetTokens is: int FGetTokens(char *pszSrc, int *prgiw)
The header for FEvalNum is: int FEvalNum(char *pszSrc, unsigned int *puVal, unsigned int *puMic)
Turn in source listings of all code comprising both lex.c and evl.c modules.
Program grading will be based on structure, style, documentation, and execution. Most of the grade will be based on execution and how your routines handle several sets of test data.
I would strongly suggest you do two things:
1) In some CFG or flowchart style notation, map out the allowable syntax for the lines described above.
2) Make the test data as you go along. My main goal in the test phase of this assignment is to bomb your program and have it miss as many test cases as possible. I'm very good at achieving my goal!!!
Datafile -------- source[0..255] source[0..255] and so on EOF Output ------ rgiw Line# [0] [1] [2] ... 1 0 3 -1 ... 2 Syntax Error and so on
Datafile -------- source[0..255] puMic source[0..255] puMic and so on Output ------ Line# puVal puMic 1 5 3 2 0 7 Error and so on
1) Two separate tar files (lex.tar & evl.tar) are to be mailed to ryand on circe where I will simply use the command tar xvf filename.tar and then make with my driver. Each of your lex.c amd evl.c modules are to include the necessary external libraries and files. Do not put these two modules in different directories. That is, place all files in the same directory, tar them up, and send them to me on circe.
2) The driver will be such that the command lexdriver datafile or evldriver datafile will read the data from the file datafile and produce the output discussed above.
If you have questions, drop me a line. Don't go down the wrong road and then have to back up. ALL of us must be operating under the same set of assumptions. Please pay particular attention to detail in this class. Example, I've had someone in the past use flxgettoken instead of FGetToken. This worked for their driver but did not compile for mine as the specification above is very specific.