First step to making tape file names arbitrary

This commit is contained in:
Jeremiah Orians 2017-04-08 14:41:50 -04:00
parent 556b9473e0
commit c1e55502d9
No known key found for this signature in database
GPG Key ID: 7457821534D2ACCD
3 changed files with 10 additions and 4 deletions

2
vm.c
View File

@ -61,6 +61,8 @@ int main(int argc, char **argv)
/* Perform all the essential stages in order */
struct lilith* vm;
tape_01_name = "tape_01";
tape_02_name = "tape_02";
vm = create_vm(1 << 21);
load_program(vm, argv);
execute_vm(vm);

4
vm.h
View File

@ -258,3 +258,7 @@ void destroy_vm(struct lilith* vm);
void read_instruction(struct lilith* vm, struct Instruction *current);
void eval_instruction(struct lilith* vm, struct Instruction* current);
void outside_of_world(struct lilith* vm, uint32_t place, char* message);
/* Allow tape names to be effectively changed */
char* tape_01_name;
char* tape_02_name;

View File

@ -163,12 +163,12 @@ void vm_FOPEN_READ(struct lilith* vm)
{
if(0x00001100 == vm->reg[0])
{
tape_01 = fopen("tape_01", "r");
tape_01 = fopen(tape_01_name, "r");
}
if (0x00001101 == vm->reg[0])
{
tape_02 = fopen("tape_02", "r");
tape_02 = fopen(tape_02_name, "r");
}
}
@ -176,12 +176,12 @@ void vm_FOPEN_WRITE(struct lilith* vm)
{
if(0x00001100 == vm->reg[0])
{
tape_01 = fopen("tape_01", "w");
tape_01 = fopen(tape_01_name, "w");
}
if (0x00001101 == vm->reg[0])
{
tape_02 = fopen("tape_02", "w");
tape_02 = fopen(tape_02_name, "w");
}
}