Archived
1
0

minor changes

This commit is contained in:
Erick
2022-01-31 23:41:51 +01:00
parent faf516e646
commit 130858d16a
2 changed files with 23 additions and 16 deletions
+4 -1
View File
@@ -53,4 +53,7 @@ dkms.conf
#folders #folders
.git/ .git/
.vscode/ .vscode/
vcpkg/
libraries/
build
+19 -15
View File
@@ -4,7 +4,7 @@
Written by Erick Ahmed, 2022 Written by Erick Ahmed, 2022
*/ */
#define __UNIX //#define __UNIX
/* universal libraries */ /* universal libraries */
#include <stdio.h> #include <stdio.h>
@@ -14,6 +14,7 @@
#include <signal.h> #include <signal.h>
/* unix only libraries */ /* unix only libraries */
// TODO: solve include errors
#ifdef __UNIX #ifdef __UNIX
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
@@ -50,14 +51,14 @@
/* Initializing 10 registers of which: /* Initializing 10 registers of which:
8 general purpose, 1 program counter, 1 conditional */ 8 general purpose, 1 program counter, 1 conditional */
enum registers { enum registers {
RG_GP0 = 0, RG_000 = 0,
RG_GP1, RG_001,
RG_GP2, RG_010,
RG_GP3, RG_011,
RG_GP4, RG_100,
RG_GP5, RG_101,
RG_GP6, RG_110,
RG_GP7, RG_111,
RG_PC, // program counter RG_PC, // program counter
RG_COND, // condition flag RG_COND, // condition flag
RG_COUNT RG_COUNT
@@ -89,9 +90,9 @@ enum opcodes {
/* Creating condition flags */ /* Creating condition flags */
enum flags { enum flags {
FL_POS = 1, // P FL_P = 1, // Positive
FL_ZRO = 1 << 1, // Z FL_Z = 1 << 1, // Zero
FL_NEG = 1 << 2, // N FL_N = 1 << 2, // Negative
}; };
@@ -110,7 +111,7 @@ int main(int argc, const char* argv[]) {
signal(SIGINT, handle_interrupt); signal(SIGINT, handle_interrupt);
disable_input_buffering(); disable_input_buffering();
reg[RG_COND] = FL_ZRO; reg[RG_COND] = FL_Z;
reg[RG_PC] = 0x3000; //0x3000 is default load address reg[RG_PC] = 0x3000; //0x3000 is default load address
int running = TRUE; int running = TRUE;
@@ -123,7 +124,10 @@ int main(int argc, const char* argv[]) {
{BR}; {BR};
break; break;
case OP_ADD: case OP_ADD:
{ADD};
// {ADD};
break; break;
case OP_LD: case OP_LD:
{LD}; {LD};
@@ -168,5 +172,5 @@ int main(int argc, const char* argv[]) {
break; break;
} }
} }
restore_input_buffering(); // shutdown restore_input_buffering(); // if shutdown then restore terminal settings
} }