Added Keys

This commit is contained in:
nplk84 2023-10-15 18:23:32 +02:00
parent 8a7d900d9a
commit 23690576ea

49
njvm.c
View File

@ -3,10 +3,6 @@
#include <stdlib.h>
#include "config.h"
unsigned int stack[100];
unsigned int current = 0;
unsigned int programmSpeicher[100];
#define IMMEDIATE(x) ((x) & 0x00FFFFFF)
#define HALT 0
@ -21,6 +17,13 @@ unsigned int programmSpeicher[100];
#define RDCHR 9
#define WRCHR 10
unsigned int programmSpeicher[1000];
// Stack
unsigned int stack[1000];
unsigned int current = 0;
void stackPush(unsigned int value){
if(current > 100) {
fprintf(stderr, "stack overflow\n");
@ -44,11 +47,7 @@ void version() {
void help() {
printf("usage: ./njvm [option] [option] ...\n\t--version\tshow version and exit\n\t--help\t\tshow this help and exit\n");
}
void printArgs(int argc, char *argv[]){
for (int i = 0; i < argc; ++i) {
printf("%s\n", argv[i]);
}
}
void useption(int argc, char *argv[]){
if (argc > 1) {
if (strcmp(argv[1], "--version") == 0) {
@ -60,9 +59,39 @@ void useption(int argc, char *argv[]){
}
}
}
void execute(){
int i = 0;
while (programmSpeicher[i] != 0) {
switch (programmSpeicher[i] >> 24) {
case HALT:
break;
case PUSHC:
break;
case ADD:
break;
case SUB:
break;
case MUL:
break;
case DIV:
break;
case MOD:
break;
case RDINT:
break;
case WRINT:
break;
case RDCHR:
break;
case WRCHR:
break;
}
i++;
}
}
int main(int argc, char *argv[]) {
printArgs(argc,argv);
if (argc > 1) useption(argc,argv);
else {