diff --git a/.gitignore b/.gitignore index 88b1075..9243d75 100644 --- a/.gitignore +++ b/.gitignore @@ -52,4 +52,5 @@ Mkfile.old dkms.conf #folders -.git/ \ No newline at end of file +.git/ +.vscode/ \ No newline at end of file diff --git a/LICENSE b/LICENSE index 96f6af0..021df6b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 Erick +Copyright (c) 2022, Erick Ahmed Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/tyvm.c b/tyvm.c index f6e43e4..b642c8e 100644 --- a/tyvm.c +++ b/tyvm.c @@ -1,10 +1,10 @@ /* TVM is a virtual machine for LC-3 based operating systems and it is used for educational purposes. - Open-source software under MIT License + Copyright (c) under MIT license Written by Erick Ahmed, 2022 */ -#define IS_UNIX +#define __UNIX /* universal libraries */ #include @@ -14,16 +14,16 @@ #include /* unix only libraries */ -#ifdef IS_UNIX +#ifdef __UNIX #include #include -#endif -/* sys libraries */ -#include -#include -#include -#include + /* sys libraries */ + #include + #include + #include + #include +#endif #define TRUE 1 #define FALSE 0 @@ -96,6 +96,19 @@ enum flags { int main(int argc, const char* argv[]) { + if(argc < 2) { + printf("usage: [image-file1] ...\n"); + exit(2); + } + + for(int i = 1; i < argc; i++) { + printf("failed to load image: %s\n", argv[i]); + exit(1); + } + + signal(SIGINT, handle_interrupt); + disable_input_buffering(); + reg[RG_COND] = FL_ZRO; reg[RG_PC] = 0x3000; //0x3000 is default load address @@ -152,9 +165,7 @@ int main(int argc, const char* argv[]) { default: {BAD_OPCODE} break; - - - - }; + } } + restore_input_buffering(); }