Skip to content
Snippets Groups Projects
Commit 0eea7de6 authored by Ben James's avatar Ben James
Browse files

branch instruction

parent f7f6372f
No related branches found
No related tags found
1 merge request!2fixed a bug
......@@ -308,6 +308,26 @@ void dataProcessingInstr(struct ProcessorState *processor, int address)
}
}
void branchInstr(struct ProcessorState *processor, uint32_t instruction)
{
// Check if address is valid
verifyAddress(address);
uint32_t instr = processor->memory[address];
// Check if the instruction should be executed according to its condition codes
if(!validCond(getBits(instr, 28, 31), processor)){
return;
}
// Calculating offset and sign
int32_t offset = getBits(instr, 0, 23);
int sign = getBits(offset, 23, 23);
// Offset shifted and extended and new address (including +8 bytes) loaded to PC
processor->registers[14] = (((offset * 4) | 0) | ((sign) ? 0 : 0xFC000000)) + 64;
return;
}
// Steps through pipeline calling appropriate instruction method.
// Sets teminate if instruction is all-0.
......
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