Skip to content
Snippets Groups Projects
Commit 97fbd1d0 authored by Christian Bay's avatar Christian Bay
Browse files

CPU: Store each jump inst in file with and without extension byte

parent 314db2d2
No related branches found
No related tags found
No related merge requests found
......@@ -663,9 +663,6 @@ cpu_step(void *_cpu_state) {
uint8_t eight_bit_src;
uint32_t four_byte_src;
/* Save old eip */
uint32_t eip_old = cpu_state->eip;
/* read the first byte from instruction pointer and increment ip
* afterards */
op_code = cpu_read_byte_from_ram(cpu_state);
......@@ -678,7 +675,16 @@ cpu_step(void *_cpu_state) {
#include "cpu_cmpInst.c"
#include "cpu_JbInst.c"
#include "cpu_JumpInst.c"
case 0x0f: {
/* The opcode is two bytes long */
uint8_t op_code_2 = cpu_read_byte_from_ram(cpu_state);
switch(op_code_2){
#include "cpu_extInst.c"
}
}
default:
break;
......@@ -686,6 +692,8 @@ cpu_step(void *_cpu_state) {
return false;
}
/** @brief nop - cpu does not support reading via bus
*/
static bool
......
......@@ -5,21 +5,21 @@ case 0x72: {
int8_t offset = cpu_read_byte_from_ram(cpu_state);
if(cpu_get_carry_flag(cpu_state)){
cpu_set_eip(cpu_state, eip_old + offset);
cpu_set_eip(cpu_state, cpu_state->eip + offset);
}
return true;
}
case 0x82: {
/* JB rel32
* Jump short if below (CF=1).
case 0x75: {
/* JNE rel8
* Jump short if not equal (ZF=0).
*/
int32_t offset = cpu_read_word_from_ram(cpu_state);
int8_t offset = cpu_read_byte_from_ram(cpu_state);
if(cpu_get_carry_flag(cpu_state)){
cpu_set_eip(cpu_state, eip_old + offset);
if(!cpu_get_zero_flag(cpu_state)){
cpu_set_eip(cpu_state, cpu_state->eip + offset);
}
return true;
}
case 0x82: {
/* JB rel32
* Jump short if below (CF=1).
*/
int32_t offset = cpu_read_word_from_ram(cpu_state);
if(cpu_get_carry_flag(cpu_state)){
cpu_set_eip(cpu_state, cpu_state->eip + offset);
}
return true;
}
case 0x85: {
/* JNE rel32
* Jump short if not equal (ZF=0).
*/
int32_t offset = cpu_read_word_from_ram(cpu_state);
if(!cpu_get_zero_flag(cpu_state)){
cpu_set_eip(cpu_state, cpu_state->eip + offset);
}
return true;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment