diff --git a/src/debug/debug.h b/src/debug/debug.h index f454fbc..a077e3c 100644 --- a/src/debug/debug.h +++ b/src/debug/debug.h @@ -1,7 +1,6 @@ #ifndef DEBUG_H #define DEBUG_H -#include #include "../toy.h" void fprintBits(size_t const size, void const * const ptr, FILE *file_pointer); diff --git a/src/main.c b/src/main.c index 5ccb7c2..3ce68fc 100644 --- a/src/main.c +++ b/src/main.c @@ -3,10 +3,29 @@ int main(int argc, char *argv[]) { - uint16_t ram[RAM_SIZE]; + uint16_t ram[RAM_SIZE]; + uint16_t ir; + uint8_t op_code; + uint16_t pc = 0; + uint16_t accu = 0; + int data_addr=0; + bool run = true; if(initialise_ram(ram,argc,argv)==-1) return 1; - makeHexDump(true,ram); +// makeHexDump(true,ram); + +// while(run && pc<(RAM_SIZE-1)) +// { + ir = ram[2]; + pc++; + op_code = get_opcode(ir); + printf("OP Code: %u\n",op_code); + data_addr=find_data(ir); + printf("Adresse: %d\n",data_addr); +// } + + + return 0; } diff --git a/src/toy.c b/src/toy.c index 50081a4..0b2dd72 100644 --- a/src/toy.c +++ b/src/toy.c @@ -58,3 +58,12 @@ uint8_t get_opcode(uint16_t instruction) return opcode; } +int find_data(uint16_t instruction) +{ + int instr; + if(instruction > 32767) instr = -1; + else instr=instruction & 4095; + return instr; +} + + diff --git a/src/toy.h b/src/toy.h index 60c0f04..d76c427 100644 --- a/src/toy.h +++ b/src/toy.h @@ -3,6 +3,7 @@ #include #include +#include #include #define RAM_SIZE 4096 @@ -11,5 +12,6 @@ int initialise_ram(uint16_t *ram, int argc, char **argv ); uint8_t get_opcode(uint16_t instruction); +int find_data(uint16_t instruction); #endif