Describe, using register transfer notation (RTN), the functionality of the following subset of the Intel x86 architecture:
ADD, MOV,
SAR, JMP.
MOV: Do not implement moffs variations, nor Control Register
variants.For detailed information about addressing modes/instructions refer to the x86 ISA manuals.
Additional Clarifications:
SIB byte addressing modes are not required for this part of the problem set.
We always use 32-bit addressing, never 16-bit addressing.
We also simplify x86 memory addressing by avoiding the GDT. Any time an
instruction accesses memory, you have to build the address based on
base+displacement as specified in the Mod R/M byte of the instruction, and add
the Segment Register shifted 16 bits. The Segment Register is always DS unless
the stack is being accessed (e.g., push and pop instructions or any other
instruction using EBP or ESP as the base register) in which case SS is the
default. Note that the default Segment Register can also be overridden with a
specific instruction prefix (not used in this problem set).
ADD (opcode 81 /0 id): ADD r/m32, imm32
MEM[GPR + SegR<<16] <- MEM[GPR + SegR<<16] + imm32
GPR <- GPR + imm32
MEM[GPR + disp32 + SegR<<16] <- MEM[GPR + disp32 + SegR<<16] + imm32
MEM[GPR + SEXT(disp8) + SegR<<16] <- MEM[GPR + SEXT(disp8) + SegR<<16] + imm32
MEM[disp32 + SegR<<16] <- MEM[disp32 + SegR<<16] + imm32
GPR stands for General Purpose Register, SegR stands for Segment Register
and MEM stands for Memory.
This describes the functionality for a single variant of ADD.
Helpful links:
Build an instruction-level simulator for a subset of x86 ISA instructions listed below (note that this is a subset different from the one in Part 1).
You must only support user-space, without address translation, and have your simulator be able to run to completion. The address space will be 32 bits and support ModR/M and SIB.
You may use whatever language you want, but your program must be able to be run from one or two terminal commands. One input must be supported for the simulator, mem.txt. Two example terminal commands for running the simulator would look like:
python3 isl.py mem.txt
or
g++ isl.cpp -o isl
./isl mem.txt
The results of this program should be a file called results.txt that displays the following information after each instruction finishes executing:
For example, if there are five instructions in the program you are testing, then there should be five print outs of all the information above. While there is no required format for the printing, do try to make it look presentable.
mem.txt will have the format shown below. You are in charge of building into your code a way of loading the instructions in mem.txt into some sort of array for your simulator.
The general format is <address>: <instruction hex>. Do not assume the //<assembly mnemonic>
portion shown in the figure above will be present in the input.
Also pay attention to how you're going to support the full 32-bit address space in your simulator without running
into issues with size.
For this assignment, we will not be concerned with interrupts or traps/faults for illegal situations. (That comes later!)
Add support of a 15 bit physical memory with a 32 bit virtual address space. To support this, a second input file will be added, tlb.txt. It will have the format shown below, being an 8 entry TLB. Do not worry about page faults being tested. The first two TLB entries will always be the same, the other six will be set as decided. Whenever a memory address is going to be loaded, you will have to call a virtual to physical conversion. Other than that, the design should be unchanged.
| Virt | Phys |
|---|---|
| 20’h00000 | 20’h00000 |
| 20’h02000 | 20’h00002 |
| 20’hxxxxx | 20’hxxxxx |
| 20’hxxxxx | 20’hxxxxx |
| 20’hxxxxx | 20’hxxxxx |
| 20’hxxxxx | 20’hxxxxx |
| 20’hxxxxx | 20’hxxxxx |
| 20’hxxxxx | 20’hxxxxx |