Commit bc050003 authored by sea19's avatar sea19
Browse files

Most tests working exluding opt_ldr11, opt_ldr12, opt_ldr13, ldr05, ldr06 & gpio_0

parent 4c689fc3
......@@ -22,7 +22,7 @@ void bigToLittleEndian(armstate *state) {
}
}
void printResult(armstate *state) {
void printResult(armstate *state, int numOfInstr) {
printf("Registers:\n");
for (int i = 0; i < 13; i++) {
printf("$%d : %d (%x)\n", i, state->regs[i], state->regs[i]);
......@@ -34,7 +34,7 @@ void printResult(armstate *state) {
void startCycle(armstate *state) {
unsigned int *pc = &(state->regs[PC]); //pc takes the value of the program counter
unsigned int fetched;
unsigned int fetched, counter = 0;
decoded *decodedInstr = (decoded *) calloc(1, sizeof(decoded));
bool finished = false;
unsigned int *objectcode = state->memory;
......@@ -61,9 +61,10 @@ void startCycle(armstate *state) {
}
}
state->regs[16] = state->n << 31 | state->z << 30 | state->c << 29 | state->v << 28;
counter++;
}
printResult(state);
printResult(state, counter);
free(decodedInstr);
} //pipeline
......
......@@ -113,11 +113,11 @@ void decode_data_processing(decoded *decodedInstr, decoded_dp *decodedDp, armsta
int carry;
if (rotate != 0) {
for (int i = 0; i < rotate; i++) {
carry = imm & 0x8000000;
carry = imm & 1;
if (carry == 0) {
imm = imm << 1;
imm = imm >> 1 & 0x7fffffff;
} else {
imm = (imm << 1) + 1;
imm = (imm >> 1) | 0x80000000;
}
}
}
......
......@@ -112,7 +112,7 @@ void tst_instr(decoded *decodedInstr, armstate *state){
decoded_dp *decodedDp = calloc(1, sizeof(decoded_dp));
decode_data_processing(decodedInstr, decodedDp, state);
unsigned int res = decodedDp -> operand2 + state -> regs[decodedDp -> rn];
unsigned int res = decodedDp -> operand2 & state -> regs[decodedDp -> rn];
if(decodedDp -> s_bit == 1){
if(res <= 0xFFFFFFFF){
......@@ -174,7 +174,7 @@ void orr_instr(decoded *decodedInstr, armstate *state){
decoded_dp *decodedDp = calloc(1, sizeof(decoded_dp));
decode_data_processing(decodedInstr, decodedDp, state);
unsigned int res = (state -> regs[decodedDp -> rn] || decodedDp -> operand2);
unsigned int res = (state -> regs[decodedDp -> rn] | decodedDp -> operand2);
state -> regs[decodedDp -> rd] = res;
if(decodedDp -> s_bit == 1){
......@@ -250,9 +250,10 @@ void single_data_transfer_instr(decoded *decodedInstr, armstate *state){
int *memAdd = (int *)(byteMem + data);
state->regs[rd] = *memAdd;
} else {
char *byteMem = (char*) state->memory;
char *memAdd = byteMem + data;
*memAdd = state->regs[rn];
/*char *byteMem = (char*) state->memory;
char *memAdd;
memAdd = byteMem + data;
*memAdd = state->regs[rn];*/
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment