discovered that I misread the spec, initial attempt at correcting the problem
This commit is contained in:
parent
2525630074
commit
53d32a2ac3
|
@ -235,29 +235,29 @@
|
||||||
** 1OPI Groups
|
** 1OPI Groups
|
||||||
1OPI i ii ii is the Immediate, a = a OP i ii ii
|
1OPI i ii ii is the Immediate, a = a OP i ii ii
|
||||||
|
|
||||||
*** Conditional Jumps
|
*** Conditional Integer Jumps
|
||||||
2C ai ii ii # JUMP.C a i ii ii :: Carry? a; PC = PC + i ii ii
|
2C 0a ii ii # JUMP.C a i ii ii :: Carry? a; PC = PC + i ii ii
|
||||||
2D ai ii ii # JUMP.B a i ii ii :: Borrow? a; PC = PC + i ii ii
|
2C 1a ii ii # JUMP.B a i ii ii :: Borrow? a; PC = PC + i ii ii
|
||||||
2E ai ii ii # JUMP.O a i ii ii :: Overflow? a; PC = PC + i ii ii
|
2C 2a ii ii # JUMP.O a i ii ii :: Overflow? a; PC = PC + i ii ii
|
||||||
2F ai ii ii # JUMP.G a i ii ii :: GT? a; PC = PC + i ii ii
|
2C 3a ii ii # JUMP.G a i ii ii :: GT? a; PC = PC + i ii ii
|
||||||
30 ai ii ii # JUMP.GE a i ii ii :: GT? a | EQ? a; PC = PC + i ii ii
|
2C 4a ii ii # JUMP.GE a i ii ii :: GT? a | EQ? a; PC = PC + i ii ii
|
||||||
31 ai ii ii # JUMP.E a i ii ii :: EQ? a; PC = PC + i ii ii
|
2C 5a ii ii # JUMP.E a i ii ii :: EQ? a; PC = PC + i ii ii
|
||||||
32 ai ii ii # JUMP.NE a i ii ii :: NEQ? a; PC = PC + i ii ii
|
2C 6a ii ii # JUMP.NE a i ii ii :: NEQ? a; PC = PC + i ii ii
|
||||||
33 ai ii ii # JUMP.LE a i ii ii :: LT? a | EQ? a; PC = PC + i ii ii
|
2C 7a ii ii # JUMP.LE a i ii ii :: LT? a | EQ? a; PC = PC + i ii ii
|
||||||
34 ai ii ii # JUMP.L a i ii ii :: LT? a; PC = PC + i ii ii
|
2C 8a ii ii # JUMP.L a i ii ii :: LT? a; PC = PC + i ii ii
|
||||||
35 ai ii ii # JUMP.Z a i ii ii :: ZERO? a; PC = PC + i ii ii
|
2C 9a ii ii # JUMP.Z a i ii ii :: ZERO? a; PC = PC + i ii ii
|
||||||
36 ai ii ii # JUMP.NZ a i ii ii :: NZERO? a; PC = PC + i ii ii
|
2C Aa ii ii # JUMP.NZ a i ii ii :: NZERO? a; PC = PC + i ii ii
|
||||||
37 xx xx xx # Reserved
|
2C Bx xx xx # Reserved
|
||||||
38 xx xx xx # Reserved
|
2C Cx xx xx # Reserved
|
||||||
39 xx xx xx # Reserved
|
2C Dx xx xx # Reserved
|
||||||
3A xx xx xx # Reserved
|
2C Ex xx xx # Reserved
|
||||||
3B xx xx xx # Reserved
|
2C Fx xx xx # Reserved
|
||||||
|
|
||||||
** 0OPI group
|
** 0OPI group
|
||||||
0OPI ii ii ii is the Immediate, OP ii ii ii
|
0OPI ii ii is the Immediate, OP ii ii
|
||||||
|
|
||||||
*** Unconditional jumps
|
*** Unconditional jumps
|
||||||
3C ii ii ii # JUMP ii ii ii :: PC = PC + ii ii ii
|
3C 00 ii ii # JUMP ii ii :: PC = PC + ii ii
|
||||||
|
|
||||||
** Reserved Block 0
|
** Reserved Block 0
|
||||||
At this time these instructions only produce a warning; but could do anything.
|
At this time these instructions only produce a warning; but could do anything.
|
||||||
|
|
59
disasm.c
59
disasm.c
|
@ -14,7 +14,7 @@ struct Instruction
|
||||||
uint32_t raw_XOP;
|
uint32_t raw_XOP;
|
||||||
char XOP[6];
|
char XOP[6];
|
||||||
char operation[9];
|
char operation[9];
|
||||||
int32_t raw_Immediate;
|
int16_t raw_Immediate;
|
||||||
char Immediate[7];
|
char Immediate[7];
|
||||||
uint32_t HAL_CODE;
|
uint32_t HAL_CODE;
|
||||||
uint8_t reg0;
|
uint8_t reg0;
|
||||||
|
@ -744,74 +744,72 @@ void decode_Integer_2OPI(struct Instruction* c)
|
||||||
void decode_1OPI(struct Instruction* c)
|
void decode_1OPI(struct Instruction* c)
|
||||||
{
|
{
|
||||||
/* Parse Raw Data */
|
/* Parse Raw Data */
|
||||||
c->raw_Immediate = (c->raw1%16)*0x10000 + c->raw2*0x100 + c->raw3;
|
c->raw_Immediate = c->raw2*0x100 + c->raw3;
|
||||||
/* Sign extend immediate*/
|
|
||||||
c->raw_Immediate = c->raw_Immediate << 12;
|
|
||||||
c->raw_Immediate = c->raw_Immediate >> 12;
|
|
||||||
c->Immediate[0] = c->operation[3];
|
c->Immediate[0] = c->operation[3];
|
||||||
c->Immediate[1] = c->operation[4];
|
c->Immediate[1] = c->operation[4];
|
||||||
c->Immediate[2] = c->operation[5];
|
c->Immediate[2] = c->operation[5];
|
||||||
c->Immediate[3] = c->operation[6];
|
c->Immediate[3] = c->operation[6];
|
||||||
c->Immediate[4] = c->operation[7];
|
c->Immediate[4] = c->operation[7];
|
||||||
c->HAL_CODE = 0;
|
c->HAL_CODE = 0;
|
||||||
c->reg0 = c->raw1/16;
|
c->raw_XOP = c->raw1/16;
|
||||||
|
c->reg0 = c->raw1%16;
|
||||||
|
|
||||||
char Name[20] = "ILLEGAL_1OPI";
|
char Name[20] = "ILLEGAL_1OPI";
|
||||||
|
|
||||||
/* Convert to Human readable form */
|
/* Convert to Human readable form */
|
||||||
switch(c->raw0)
|
switch(c->raw_XOP)
|
||||||
{
|
{
|
||||||
case 0x2C: /* JUMP.C */
|
case 0x0: /* JUMP.C */
|
||||||
{
|
{
|
||||||
strncpy(Name, "JUMP.C", 19);
|
strncpy(Name, "JUMP.C", 19);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x2D: /* JUMP.B */
|
case 0x1: /* JUMP.B */
|
||||||
{
|
{
|
||||||
strncpy(Name, "JUMP.B", 19);
|
strncpy(Name, "JUMP.B", 19);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x2E: /* JUMP.O */
|
case 0x2: /* JUMP.O */
|
||||||
{
|
{
|
||||||
strncpy(Name, "JUMP.O", 19);
|
strncpy(Name, "JUMP.O", 19);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x2F: /* JUMP.G */
|
case 0x3: /* JUMP.G */
|
||||||
{
|
{
|
||||||
strncpy(Name, "JUMP.G", 19);
|
strncpy(Name, "JUMP.G", 19);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x30: /* JUMP.GE */
|
case 0x4: /* JUMP.GE */
|
||||||
{
|
{
|
||||||
strncpy(Name, "JUMP.GE", 19);
|
strncpy(Name, "JUMP.GE", 19);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x31: /* JUMP.E */
|
case 0x5: /* JUMP.E */
|
||||||
{
|
{
|
||||||
strncpy(Name, "JUMP.E", 19);
|
strncpy(Name, "JUMP.E", 19);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x32: /* JUMP.NE */
|
case 0x6: /* JUMP.NE */
|
||||||
{
|
{
|
||||||
strncpy(Name, "JUMP.NE", 19);
|
strncpy(Name, "JUMP.NE", 19);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x33: /* JUMP.LE */
|
case 0x7: /* JUMP.LE */
|
||||||
{
|
{
|
||||||
strncpy(Name, "JUMP.LE", 19);
|
strncpy(Name, "JUMP.LE", 19);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x34: /* JUMP.L */
|
case 0x8: /* JUMP.L */
|
||||||
{
|
{
|
||||||
strncpy(Name, "JUMP.L", 19);
|
strncpy(Name, "JUMP.L", 19);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x35: /* JUMP.Z */
|
case 0x9: /* JUMP.Z */
|
||||||
{
|
{
|
||||||
strncpy(Name, "JUMP.Z", 19);
|
strncpy(Name, "JUMP.Z", 19);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x36: /* JUMP.NZ */
|
case 0xA: /* JUMP.NZ */
|
||||||
{
|
{
|
||||||
strncpy(Name, "JUMP.NZ", 19);
|
strncpy(Name, "JUMP.NZ", 19);
|
||||||
break;
|
break;
|
||||||
|
@ -829,23 +827,22 @@ void decode_1OPI(struct Instruction* c)
|
||||||
void decode_0OPI(struct Instruction* c)
|
void decode_0OPI(struct Instruction* c)
|
||||||
{
|
{
|
||||||
/* Parse Raw Data */
|
/* Parse Raw Data */
|
||||||
c->raw_Immediate = c->raw1*0x10000 + c->raw2*0x100 + c->raw3;
|
c->raw_Immediate = c->raw2*0x100 + c->raw3;
|
||||||
/* Sign extend immediate*/
|
c->Immediate[0] = c->operation[4];
|
||||||
c->raw_Immediate = c->raw_Immediate << 8;
|
c->Immediate[1] = c->operation[5];
|
||||||
c->raw_Immediate = c->raw_Immediate >> 8;
|
c->Immediate[2] = c->operation[6];
|
||||||
c->Immediate[0] = c->operation[2];
|
c->Immediate[3] = c->operation[7];
|
||||||
c->Immediate[1] = c->operation[3];
|
c->HAL_CODE = 0;
|
||||||
c->Immediate[2] = c->operation[4];
|
c->raw_XOP = c->raw1;
|
||||||
c->Immediate[3] = c->operation[5];
|
c->XOP[0] = c->operation[2];
|
||||||
c->Immediate[4] = c->operation[6];
|
c->XOP[1] = c->operation[3];
|
||||||
c->Immediate[5] = c->operation[7];
|
|
||||||
|
|
||||||
char Name[20] = "ILLEGAL_0OPI";
|
char Name[20] = "ILLEGAL_0OPI";
|
||||||
|
|
||||||
/* Convert to Human readable form */
|
/* Convert to Human readable form */
|
||||||
switch(c->raw0)
|
switch(c->raw_XOP)
|
||||||
{
|
{
|
||||||
case 0x3C: /* JUMP */
|
case 0x00: /* JUMP */
|
||||||
{
|
{
|
||||||
strncpy(Name, "JUMP", 19);
|
strncpy(Name, "JUMP", 19);
|
||||||
break;
|
break;
|
||||||
|
@ -939,7 +936,7 @@ void eval_instruction(struct Instruction* c)
|
||||||
decode_Integer_2OPI(c);
|
decode_Integer_2OPI(c);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x2C ... 0x3B: /* Core 1OPI */
|
case 0x2C: /* Core 1OPI */
|
||||||
{
|
{
|
||||||
decode_1OPI(c);
|
decode_1OPI(c);
|
||||||
break;
|
break;
|
||||||
|
|
53
vm.c
53
vm.c
|
@ -1126,8 +1126,8 @@ bool eval_2OPI_Int(struct lilith* vm, struct Instruction* c)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Process 1OPI instructions */
|
/* Process 1OPI Integer instructions */
|
||||||
bool eval_1OPI(struct lilith* vm, struct Instruction* c)
|
bool eval_Integer_1OPI(struct lilith* vm, struct Instruction* c)
|
||||||
{
|
{
|
||||||
bool C, B, O, GT, EQ, LT;
|
bool C, B, O, GT, EQ, LT;
|
||||||
uint32_t tmp;
|
uint32_t tmp;
|
||||||
|
@ -1141,10 +1141,10 @@ bool eval_1OPI(struct lilith* vm, struct Instruction* c)
|
||||||
EQ = tmp & EQual;
|
EQ = tmp & EQual;
|
||||||
LT = tmp & LessThan;
|
LT = tmp & LessThan;
|
||||||
|
|
||||||
/* 0x2C ... 0x3B */
|
/* 0x2C */
|
||||||
switch(c->raw0)
|
switch(c->raw_XOP)
|
||||||
{
|
{
|
||||||
case 0x2C: /* JUMP.C */
|
case 0x0: /* JUMP.C */
|
||||||
{
|
{
|
||||||
if(1 == C)
|
if(1 == C)
|
||||||
{
|
{
|
||||||
|
@ -1153,7 +1153,7 @@ bool eval_1OPI(struct lilith* vm, struct Instruction* c)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x2D: /* JUMP.B */
|
case 0x1: /* JUMP.B */
|
||||||
{
|
{
|
||||||
if(1 == B)
|
if(1 == B)
|
||||||
{
|
{
|
||||||
|
@ -1162,7 +1162,7 @@ bool eval_1OPI(struct lilith* vm, struct Instruction* c)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x2E: /* JUMP.O */
|
case 0x2: /* JUMP.O */
|
||||||
{
|
{
|
||||||
if(1 == O)
|
if(1 == O)
|
||||||
{
|
{
|
||||||
|
@ -1171,7 +1171,7 @@ bool eval_1OPI(struct lilith* vm, struct Instruction* c)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x2F: /* JUMP.G */
|
case 0x3: /* JUMP.G */
|
||||||
{
|
{
|
||||||
if(1 == GT)
|
if(1 == GT)
|
||||||
{
|
{
|
||||||
|
@ -1180,7 +1180,7 @@ bool eval_1OPI(struct lilith* vm, struct Instruction* c)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x30: /* JUMP.GE */
|
case 0x4: /* JUMP.GE */
|
||||||
{
|
{
|
||||||
if((1 == GT) || (1 == EQ))
|
if((1 == GT) || (1 == EQ))
|
||||||
{
|
{
|
||||||
|
@ -1189,7 +1189,7 @@ bool eval_1OPI(struct lilith* vm, struct Instruction* c)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x31: /* JUMP.E */
|
case 0x5: /* JUMP.E */
|
||||||
{
|
{
|
||||||
if(1 == EQ)
|
if(1 == EQ)
|
||||||
{
|
{
|
||||||
|
@ -1198,7 +1198,7 @@ bool eval_1OPI(struct lilith* vm, struct Instruction* c)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x32: /* JUMP.NE */
|
case 0x6: /* JUMP.NE */
|
||||||
{
|
{
|
||||||
if(1 != EQ)
|
if(1 != EQ)
|
||||||
{
|
{
|
||||||
|
@ -1207,7 +1207,7 @@ bool eval_1OPI(struct lilith* vm, struct Instruction* c)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x33: /* JUMP.LE */
|
case 0x7: /* JUMP.LE */
|
||||||
{
|
{
|
||||||
if((1 == EQ) || (1 == LT))
|
if((1 == EQ) || (1 == LT))
|
||||||
{
|
{
|
||||||
|
@ -1216,7 +1216,7 @@ bool eval_1OPI(struct lilith* vm, struct Instruction* c)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x34: /* JUMP.L */
|
case 0x8: /* JUMP.L */
|
||||||
{
|
{
|
||||||
if(1 == LT)
|
if(1 == LT)
|
||||||
{
|
{
|
||||||
|
@ -1225,7 +1225,7 @@ bool eval_1OPI(struct lilith* vm, struct Instruction* c)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x35: /* JUMP.Z */
|
case 0x9: /* JUMP.Z */
|
||||||
{
|
{
|
||||||
if(0 == tmp)
|
if(0 == tmp)
|
||||||
{
|
{
|
||||||
|
@ -1234,7 +1234,7 @@ bool eval_1OPI(struct lilith* vm, struct Instruction* c)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x36: /* JUMP.NZ */
|
case 0xA: /* JUMP.NZ */
|
||||||
{
|
{
|
||||||
if(0 != tmp)
|
if(0 != tmp)
|
||||||
{
|
{
|
||||||
|
@ -1248,6 +1248,21 @@ bool eval_1OPI(struct lilith* vm, struct Instruction* c)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Process 0OPI Integer instructions */
|
||||||
|
bool eval_Integer_0OPI(struct lilith* vm, struct Instruction* c)
|
||||||
|
{
|
||||||
|
switch(c->raw_XOP)
|
||||||
|
{
|
||||||
|
case 0x00: /* JUMP */
|
||||||
|
{
|
||||||
|
vm->ip = vm->ip + c->raw_Immediate - 4;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* Use Opcode to decide what to do and then have it done */
|
/* Use Opcode to decide what to do and then have it done */
|
||||||
void eval_instruction(struct lilith* vm, struct Instruction* current)
|
void eval_instruction(struct lilith* vm, struct Instruction* current)
|
||||||
{
|
{
|
||||||
|
@ -1294,18 +1309,18 @@ void eval_instruction(struct lilith* vm, struct Instruction* current)
|
||||||
if ( invalid) goto fail;
|
if ( invalid) goto fail;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x2C ... 0x3B:
|
case 0x2C:
|
||||||
{
|
{
|
||||||
decode_1OPI(current);
|
decode_1OPI(current);
|
||||||
invalid = eval_1OPI(vm, current);
|
invalid = eval_Integer_1OPI(vm, current);
|
||||||
if ( invalid) goto fail;
|
if ( invalid) goto fail;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x3C: /* JUMP */
|
case 0x3C: /* JUMP */
|
||||||
{
|
{
|
||||||
decode_0OPI(current);
|
decode_0OPI(current);
|
||||||
/* Adust the IP relative the the start of this instruction*/
|
invalid = eval_Integer_0OPI(vm, current);
|
||||||
vm->ip = vm->ip + current->raw_Immediate - 4;
|
if ( invalid) goto fail;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x42: /* HALCODE */
|
case 0x42: /* HALCODE */
|
||||||
|
|
39
vm.h
39
vm.h
|
@ -23,7 +23,7 @@ struct Instruction
|
||||||
uint32_t raw_XOP;
|
uint32_t raw_XOP;
|
||||||
char XOP[6];
|
char XOP[6];
|
||||||
char operation[9];
|
char operation[9];
|
||||||
int32_t raw_Immediate;
|
int16_t raw_Immediate;
|
||||||
char Immediate[7];
|
char Immediate[7];
|
||||||
uint32_t HAL_CODE;
|
uint32_t HAL_CODE;
|
||||||
uint8_t reg0;
|
uint8_t reg0;
|
||||||
|
@ -129,31 +129,28 @@ void decode_2OPI(struct Instruction* c)
|
||||||
/* Deal with 1OPI */
|
/* Deal with 1OPI */
|
||||||
void decode_1OPI(struct Instruction* c)
|
void decode_1OPI(struct Instruction* c)
|
||||||
{
|
{
|
||||||
c->raw_Immediate = (c->raw1%16)*0x10000 + c->raw2*0x100 + c->raw3;
|
c->raw_Immediate = c->raw2*0x100 + c->raw3;
|
||||||
/* Sign extend immediate*/
|
c->Immediate[0] = c->operation[4];
|
||||||
c->raw_Immediate = c->raw_Immediate << 12;
|
c->Immediate[1] = c->operation[5];
|
||||||
c->raw_Immediate = c->raw_Immediate >> 12;
|
c->Immediate[2] = c->operation[6];
|
||||||
c->Immediate[0] = c->operation[3];
|
c->Immediate[3] = c->operation[7];
|
||||||
c->Immediate[1] = c->operation[4];
|
|
||||||
c->Immediate[2] = c->operation[5];
|
|
||||||
c->Immediate[3] = c->operation[6];
|
|
||||||
c->Immediate[4] = c->operation[7];
|
|
||||||
c->HAL_CODE = 0;
|
c->HAL_CODE = 0;
|
||||||
c->reg0 = c->raw1/16;
|
c->raw_XOP = c->raw1/16;
|
||||||
|
c->XOP[0] = c->operation[2];
|
||||||
|
c->reg0 = c->raw1%16;
|
||||||
}
|
}
|
||||||
/* Deal with 0OPI */
|
/* Deal with 0OPI */
|
||||||
void decode_0OPI(struct Instruction* c)
|
void decode_0OPI(struct Instruction* c)
|
||||||
{
|
{
|
||||||
c->raw_Immediate = c->raw1*0x10000 + c->raw2*0x100 + c->raw3;
|
c->raw_Immediate = c->raw2*0x100 + c->raw3;
|
||||||
/* Sign extend immediate*/
|
c->Immediate[0] = c->operation[4];
|
||||||
c->raw_Immediate = c->raw_Immediate << 8;
|
c->Immediate[1] = c->operation[5];
|
||||||
c->raw_Immediate = c->raw_Immediate >> 8;
|
c->Immediate[2] = c->operation[6];
|
||||||
c->Immediate[0] = c->operation[2];
|
c->Immediate[3] = c->operation[7];
|
||||||
c->Immediate[1] = c->operation[3];
|
c->HAL_CODE = 0;
|
||||||
c->Immediate[2] = c->operation[4];
|
c->raw_XOP = c->raw1;
|
||||||
c->Immediate[3] = c->operation[5];
|
c->XOP[0] = c->operation[2];
|
||||||
c->Immediate[4] = c->operation[6];
|
c->XOP[1] = c->operation[3];
|
||||||
c->Immediate[5] = c->operation[7];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Deal with Halcode */
|
/* Deal with Halcode */
|
||||||
|
|
Loading…
Reference in New Issue