Corrected HALCODE oversight

This commit is contained in:
Jeremiah Orians 2016-06-12 19:18:11 -04:00
parent 5f4e55b309
commit ad8d67a0f4
No known key found for this signature in database
GPG Key ID: 7457821534D2ACCD
5 changed files with 63 additions and 33 deletions

View File

@ -411,12 +411,14 @@ The following 3 devices must exist with the following exact IDs
| Tape 2 | 00 00 11 01 |
**** Required Device HALCODE
| Hex | Name | Comment |
|-------------+--------+----------------------------------------------------------------------------------------------------------------------------------|
| 42 10 00 00 | FOPEN | Feed on device who's ID matches the contents register 0 until first non-zero byte is found. |
| 42 10 00 01 | FCLOSE | Close out writes to device who's ID matches the contents of register 0. |
| 42 10 00 02 | FSEEK | seek forward or backward the number of bytes specified in register 1 on the device who's ID matches the contents of register 0. |
| 42 10 00 03 | REWIND | rewind back to first non-zero byte found on tape. |
| Hex | Name | Comment |
|-------------+-------------+------------------------------------------------------------------------------------------------|
| 42 10 00 00 | FOPEN_READ | Feed on device who's ID matches the contents of register 0 until first non-zero byte is found. |
| 42 10 00 01 | FOPEN_WRITE | Feed on device who's ID matches the contents of register 0 until first zero byte is found |
| 42 10 00 02 | FCLOSE | Close out writes to device who's ID matches the contents of register 0. |
| 42 10 00 03 | REWIND | rewind back to first non-zero byte found on tape. |
| 42 10 00 04 | FSEEK | seek forward or backward the number of bytes specified in register 1 on |
| | | the device who's ID matches the contents of register 0. |
**** Reserved Block for Hardware specific implementation details
| Hex | Name |

8
asm.c
View File

@ -309,14 +309,14 @@ void assemble(struct Token* p)
setExpression(p, "JUMP", "3C00", 4);
/* HALCODE Group */
setExpression(p, "FOPEN", "42100000", 4);
setExpression(p, "FCLOSE", "42100001", 4);
setExpression(p, "FSEEK", "42100002", 4);
setExpression(p, "FOPEN_READ", "42100000", 4);
setExpression(p, "FOPEN_WRITE", "42100001", 4);
setExpression(p, "FCLOSE", "42100002", 4);
setExpression(p, "REWIND", "42100003", 4);
setExpression(p, "FSEEK", "42100004", 4);
setExpression(p, "FGETC", "42100100", 4);
setExpression(p, "FPUTC", "42100200", 4);
//setExpression(p, "", "");
/* 0OP Group*/
setExpression(p, "NOP", "00000000", 4);
setExpression(p, "HALT", "FFFFFFFF", 4);

View File

@ -980,26 +980,31 @@ void decode_HALCODE(struct Instruction* c)
/* Convert to Human readable form */
switch(c->HAL_CODE)
{
case 0x100000: /* FOPEN */
case 0x100000: /* FOPEN_READ */
{
strncpy(Name, "FOPEN", 19);
strncpy(Name, "FOPEN_READ", 19);
break;
}
case 0x100001: /* FCLOSE */
case 0x100001: /* FOPEN_WRITE */
{
strncpy(Name, "FOPEN_WRITE", 19);
break;
}
case 0x100002: /* FCLOSE */
{
strncpy(Name, "FCLOSE", 19);
break;
}
case 0x100002: /* FSEEK */
{
strncpy(Name, "FSEEK", 19);
break;
}
case 0x100003: /* REWIND */
{
strncpy(Name, "REWIND", 19);
break;
}
case 0x100004: /* FSEEK */
{
strncpy(Name, "FSEEK", 19);
break;
}
case 0x100100: /* FGETC */
{
strncpy(Name, "FGETC", 19);

38
vm.c
View File

@ -3,7 +3,8 @@
uint32_t performance_counter;
/* Prototypes for functions in vm_instructions.c*/
void vm_FOPEN(struct lilith* vm);
void vm_FOPEN_READ(struct lilith* vm);
void vm_FOPEN_WRITE(struct lilith* vm);
void vm_FCLOSE(struct lilith* vm);
void vm_FSEEK(struct lilith* vm);
void vm_REWIND(struct lilith* vm);
@ -318,16 +319,25 @@ bool eval_HALCODE(struct lilith* vm, struct Instruction* c)
switch(c->HAL_CODE)
{
case 0x100000: /* fopen */
case 0x100000: /* fopen_read */
{
#ifdef DEBUG
strncpy(Name, "FOPEN", 19);
strncpy(Name, "FOPEN_READ", 19);
#endif
vm_FOPEN(vm);
vm_FOPEN_READ(vm);
break;
}
case 0x100001: /* fclose */
case 0x100001: /* fopen_write */
{
#ifdef DEBUG
strncpy(Name, "FOPEN_WRITE", 19);
#endif
vm_FOPEN_WRITE(vm);
break;
}
case 0x100002: /* fclose */
{
#ifdef DEBUG
strncpy(Name, "FCLOSE", 19);
@ -336,15 +346,6 @@ bool eval_HALCODE(struct lilith* vm, struct Instruction* c)
vm_FCLOSE(vm);
break;
}
case 0x100002: /* fseek */
{
#ifdef DEBUG
strncpy(Name, "FSEEK", 19);
#endif
vm_FSEEK(vm);
break;
}
case 0x100003: /* rewind */
{
#ifdef DEBUG
@ -354,6 +355,15 @@ bool eval_HALCODE(struct lilith* vm, struct Instruction* c)
vm_REWIND(vm);
break;
}
case 0x100004: /* fseek */
{
#ifdef DEBUG
strncpy(Name, "FSEEK", 19);
#endif
vm_FSEEK(vm);
break;
}
case 0x100100: /* fgetc */
{
#ifdef DEBUG

View File

@ -128,13 +128,26 @@ uint32_t shift_register(uint32_t source, uint32_t amount, bool left, bool zero)
return tmp;
}
void vm_FOPEN(struct lilith* vm)
void vm_FOPEN_READ(struct lilith* vm)
{
if(0x00001100 == vm->reg[0])
{
tape_01 = fopen("tape_01", "r");
}
if (0x00001101 == vm->reg[0])
{
tape_02 = fopen("tape_02", "r");
}
}
void vm_FOPEN_WRITE(struct lilith* vm)
{
if(0x00001100 == vm->reg[0])
{
tape_01 = fopen("tape_01", "w");
}
if (0x00001101 == vm->reg[0])
{
tape_02 = fopen("tape_02", "w");