CS520
Spring 2014
Laboratory 6
Monday March 3
The lab must be submitted prior to 8am on Tuesday March 4.
The goal for this lab is to complete the first 60 points of
Program 3.
Here is how the required vm520 instructions are translated to Intel 64
instructions:
- The initial JMP label => JMP DISPL (where DISPL is 8 * the number of
data words being skipped plus the number of padding bytes)
(if 7 data words and 3 padding bytes, then Intel instruction encoded as 0xE9 0x3B 0x00 0x00 0x00)
- HALT => RET (encoded as 0xC3)
- LOAD R0, X => MOVQ OFFSET(%rdi), R8 (where OFFSET is address(X) * 8)
(if address(X) == 2 then Intel instruction encoded as 0x4C 0x8B 0x87 0x10 0x00 0x00 0x00)
- STORE R0, X => MOVQ R8, OFFSET(%rdi) (where OFFSET is address(X) * 8)
(if address(X) == 2 then Intel instruction encoded as 0x4C 0x89 0x87 0x10 0x00 0x00 0x00)
- LDIMM R0, 1 => MOVQ $1, R8 (encoded as 49 C7 C0 01 00 00 00)
There are some sample object files available on agate in
~cs520/public/lab6.
Remember that your program is intended to process object files,
and not the assembly language source files.
You can also create your own tests using the
vm520
assembler,
called as520.
And you can look inside an object file using the
vm520
disassembler,
called dis520.
Both of these tools are installed on agate in ~cs520/bin.
It may be helpful to use the Linux assembler to assemble sample
Intel 64 instructions and look at how they are encoded.
Use the -al flag to get a display of the encoded instructions.
For example, as -al file.s.
Points will be awarded for the lab in the following way:
- (20 points) HALT.
- (10 points) LDIMM.
- (10 points) STORE.
- (10 points) LOAD.
Note: you are only submitting one file, translateBinary.c, so
do not put any of your code in any other file.
In particular, translateBinary.c should not include any files that
you created.
It should only include standard system header files.
In addition, it should not contain a main function,
nor should it contain the allocateInstructionBuffer function.
To turn in this laboratory, type:
~cs520/bin/submit lab6 translateBinary.c
Submissions can be checked by typing:
~cs520/bin/scheck lab6
Last modified on February 23, 2014.
Comments and questions should be directed to
hatcher@unh.edu