Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

C语言代写 | OBJ file Programming

C语言代写 | OBJ file Programming



Setting up Codio for this HW:

1) Open the Codio assignment via Coursera
2) From the Codio File-Tree click on: lc4_memory.h and lc4_memory.c
3) Remember to use the Codio “Test Compile” function before submitting the assignment.


The goal of this HW is for you to write a program that can open and read in a .OBJ file created
by PennSim, parse it, and load it into a linked list that will represent the LC4’s program and data
memories (similar to what PennSim’s “loader” does). In the last HW, you created a .OBJ file. In
this HW, you will be able to read in a .OBJ file and convert it back to the assembly it came from!
This is known as reverse assembling (sometimes a disassembler).


The following is the format for the binary .OBJ files created by PennSim from your .ASM files. It
represents the contents of memory (both program and data) for your assembled LC-4 Assembly
programs. In a .OBJ file, there are 3 basic sections indicated by 3 header “types” = CODE, DATA,

● Code: 3-word header (xCADE, <address>, <n>), n-word body comprising the instructions.
This corresponds to the .CODE directive in assembly.

● Data: 3-word header (xDADA, <address>, <n>), n-word body comprising the initial data
values. This corresponds to the .DATA directive in assembly.

● Symbol: 3-word header (xC3B7, <address>, <n>), n-character body comprising the
symbol string. Note, each character in the file is 1 byte, not 2. There is no null
terminator . Each symbol is its own section. These are generated when you create labels
(such as “END”) in assembly.


In the file: lc4_memory.h, you’ll see the following structure defined:

The structure is meant to model a row of the LC4’s memory: a 16-bit address, & its 16-bit
contents. As you know, an address may also have a label associated with it. You will also recall
that PennSim always shows the contents of memory in its “assembly” form. So PennSim
reverse-assembles the contents and displays the assembly instruction itself (instead of the
binary contents).

As part of this assignment, you will read in a .OBJ file and store each instruction in a NODE of
the type above. Since they’ll be an unknown # of instructions in the file, you’ll create a linked
list of the nodes above to hold all the instructions that are in the .OBJ file.

The details of how to implement all of this will be discussed in the sections of this document
that follow.