Laboratory 6 [2/24; 2/26] The Two Pass Assembler Part I:
Encoding Opcodes
Do the following prior to the laboratory.
- Create a separate directory and download the following
programs:
- Perform a make to be sure that you have downloaded
the programs correctly.
- Modify checkopcodes.c to do the following:
- If the number of command line arguments is incorrect,
output a Usage message and exit.
- Use the command line argument as a filename. Open the file
for reading.
- Read the file one line at a time until
end-of-file using fgets.
- Echo the line to standard output and then process the line as follows:
- Use strtok to peel off the tokens one at a time.
- Output each token on a separate line along with whether or not it
is an opcode. Your program should determine this by calling
get_opcode with the appropriate arguments.
If it is an opcode, output the op field
in HEX.
- Modify opcodes.c so that it performs
as indicated in the documentation.
During laboratory checkoff a file will be made available for
you to run your program. You must hand in copies of all source,
your makefile, and your lint output. There should be no lint
errors.
You can test your program on the following
sample program.
Revision Date: 2/17/97 at 1:50 pm