Skip to content
Snippets Groups Projects
Commit fe8811e4 authored by iftach's avatar iftach
Browse files

clarified the spec a little bit

parent 62f97a54
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,8 @@ struct ProcessorState
If the first instruction after a jump is another jump (or if the first instruction of a program is a jump) this might cause a problem (?)
since in an actual execution the offset starts at 0 and moves to +8 after two instructions. decode() should probably account for this.
IMPLEMENTED
Remember to check memory's bounds before accessing it!
main
uses: loadBinary(...), step(...)
......@@ -15,23 +17,22 @@ void step(struct ProcessorState *processor)
uses: dataProcessingInstr(...), multiplyInstr(...), dataTransferInstr(...), branchInstr(...)
void dataProcessingInstr(struct ProcessorState *processor, int address)
Executes a data processing instruction
Executes a data processing instruction stored in (*processor).memory[address]
uses: isValidCond(...), barrelShift(...)
void multiplyInstr(struct ProcessorState *processor, int address)
Executes a multiplication instruction
uses: isValidCond(...),
Executes a multiplication instruction stored in (*processor).memory[address]
uses: isValidCond(...)
void dataTransferInstr(struct ProcessorState *processor, int address)
Executes a single data transfer instruction
Executes a single data transfer instruction stored in (*processor).memory[address]
uses: isValidCond(...), barrelShift(...)
void branchInstr(stuct ProcessorState *processor, int address)
uses: isValidCond(...),
uses: isValidCond(...),
struct ProcessorState *loadBinary(char* src)
creates a new processor and loads its memory from a binary file.
creates a new ProcessorState and loads its memory from a binary file.
Helper functions (used in more than one method):
......@@ -51,7 +52,7 @@ int validCond(int cond, struct ProcessorState *processor)
IMPLEMENTED
int32_t barrelShift(int immediate, int32_t operand, int *carry, struct ProcessorState *processor)
Implements the functionality of the barrel shifter
Implements the functionality of the barrel shifter. The carry output is written to (*carry), just in case you need it.
NOTE: for some reason the I bit is used in opposite ways for data processing instructions vs for data transfer instructions. Arbitrarily, let this method
assume that the data processing instruction interpretation is the right one (so for data transfer instructions just call this method with NOT i).
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment