Assignment 6, due June 30

Machine Problem 3, due July 6

Part of the homework for 22C:50, Summer 2004
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

Machine Problem 3, due July 6

Modifications to EAL

Create a working directory called mp3, and then either: Install the source code from

http://www.cs.uiowa.edu/~jones/syssoft/hw/mp0.txt
Or make a copy of your solution to MP1 or MP2 to this directory and continue development here, so you end up with your solutions integrated into one program.

Having done this, note that the assembler, as currently configured, produces no object code output other than the assembly listing.

Modify the code so it creates an object file. If the source file is file.a, the listing file, as currently created, will be file.l. Your object file should called file.o and it should be opened similarly.

Data in your object file should be in binary, not text, and it should have thehave the following format:

Set loader's location counter:
Byte 1: 1, the tag
Byte 2: High 8 bits of address
Byte 3: Low 8 bits of address
Load byte in memory
Byte 1: 2, the tag
Byte 2: Data
Load word in memory
Byte 1: 3, the tag
Byte 2: High 8 bits of data
Byte 3: Low 8 bits of data

Make sure that all of your code conforms to the style guidelines

http://www.cs.uiowa.edu/~jones/syssoft/style.html
Pay close attention to indenting (depending on how you downloaded your code, tab-to-space conversion may have seriously damaged the indenting), and pay close attention to the commenting rules for documenting revisions. Specifically, use comments of the form /*MP3*/ to mark any line you added, and add an appropriate revision line to the header block of any file you change.

Testing

Write an EAL program that thoroughly tests your modified code, specifically, this should demonstrate the correct generation of all of the object code items discussed above, and it should demonstrate the efficiency or inefficiency of your object code representation. (Efficiency issues arise with this code because of the possibility that you might generate unnecessary type-1 output records..

Here is a little program to read object files in this format. Use it to create human-readable listings of the object files produced by your assembler.

#include <stdio.h>
main() {
        for (;;) {
                int byte1;
                byte1 = getchar();
                if (byte1 == EOF) { puts("; normal EOF"); exit(-1); }
                if (byte1 == 1) {
                        int byte2 = getchar();
                        int byte3 = getchar();
                        printf( ". = #%04X\n", (byte2 << 8) + (byte3 & 0xFF) );
                	if (byte2 == EOF) puts("; unexpected EOF high byte");
                	if (byte3 == EOF) puts("; unexpected EOF low byte");
                } else if (byte1 == 2) {
                        int byte2 = getchar();
                        printf( "  B #%02X\n", byte2 & 0xFF );
                	if (byte2 == EOF) puts("; unexpected EOF");
                } else if (byte1 == 3) {
                        int byte2 = getchar();
                        int byte3 = getchar();
                        printf( "  W #%04X\n", (byte2 << 8) + (byte3 & 0xFF) );
                	if (byte2 == EOF) puts("; unexpected EOF high byte");
                	if (byte3 == EOF) puts("; unexpected EOF low byte");
                } else {
                        printf("; unexpected %02X\n", byte1 );
                }
        }
}

Turn in

Paper listings of every file from the EAL source code that you changed (obviously, objectcode.c will be one of these). and a paper listing of the listing file produced by EAL when it processes your test data.

In addition, show the output of the above skeleton test program when it is given the object code from your test data as input, so the original assembly code listing and the object file listing can be compared.

Assignment 6, due June 30

  1. Do problems 3 and 9 in Chapter 7.

  2. Do problem 2 from Chapter 8, but specifically, use the C fgetc function to read individual characters from open input stream, and use it to implement mygets(), a routine that reads a line from the stream. The semantics of your mygets should match that of fgets, and you can use the Unix man command to look up both fgetc and fgets on any Unix or Linux system. You can test your code if you want to.

  3. Write, in C, a loader for the object language given in the new machine problem. This should load directly into memory instead of producing a listing, as in the test code given above. Note that you're not likely to be able to actually run this loader.