Add file input | Add opcodes to design

This commit is contained in:
XOR 2022-12-16 10:56:34 +01:00
parent 8a2108897c
commit 755149ec5e
4 changed files with 52 additions and 11 deletions

1
.gitignore vendored
View file

@ -36,6 +36,7 @@
*.i*86
*.x86_64
*.hex
interpreter
# Debug files
*.dSYM/

7
Makefile Normal file
View file

@ -0,0 +1,7 @@
all: compile run
compile:
gcc main.c -o interpreter
run:
./interpreter

View file

@ -1,15 +1,15 @@
Instructions:
INP
OUT
LDA
STA
INC
DEC
JPP
JPZ
JPN
JPU
EOJ
INP 0b0001
OUT 0b0010
LDA 0b0011
STA 0b0100
INC 0b0101
DEC 0b0110
JPP 0b0111
JPZ 0b1000
JPN 0b1001
JPU 0b1010
EOJ 0b1011
Instruction format, [] means optional:
instruction [mem_adress]; [Kommentar]

33
main.c Normal file
View file

@ -0,0 +1,33 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAX_MEMORY 1000000
// 0 = Operation | 1 = Adress | 2 = Comment
int instruction_part=0;
int main(int argc, char const *argv[])
{
printf("-----------------\nEIPA Interpreter\n-----------------\n");
char assembly_path[]= "test.eipa";
FILE *assembly_file = fopen(assembly_path,"r");
if(assembly_file==NULL)
{
return 0;
}
int *instructions = malloc(MAX_MEMORY*sizeof(int8_t));
char current_char = fgetc(assembly_file);
char instruction_part_string[10];
while(current_char!=EOF)
{
printf("%c",current_char);
current_char = fgetc(assembly_file);
}
fclose(assembly_file);
return 0;
}