c# implementation using new i/o instructions
FossilOrigin-Name: b6c0c757cbf7095ea30aa7b62aa9d2e6a0bc9137012b1746bc2c3c239cf46ecb
This commit is contained in:
parent
49525f2ebd
commit
1236b51664
1 changed files with 17 additions and 9 deletions
|
@ -2,7 +2,7 @@
|
||||||
* Nga Virtual Machine & Interface for RETRO 12
|
* Nga Virtual Machine & Interface for RETRO 12
|
||||||
*
|
*
|
||||||
* Copyright (c) 2009-2011, Simon Waite
|
* Copyright (c) 2009-2011, Simon Waite
|
||||||
* Copyright (c) 2009-2017, Charles Childers
|
* Copyright (c) 2009-2018, Charles Childers
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
@ -31,7 +31,8 @@ namespace Nga
|
||||||
VM_FETCH, VM_STORE, VM_ADD,
|
VM_FETCH, VM_STORE, VM_ADD,
|
||||||
VM_SUB, VM_MUL, VM_DIVMOD,
|
VM_SUB, VM_MUL, VM_DIVMOD,
|
||||||
VM_AND, VM_OR, VM_XOR,
|
VM_AND, VM_OR, VM_XOR,
|
||||||
VM_SHIFT, VM_ZRET, VM_END
|
VM_SHIFT, VM_ZRET, VM_END,
|
||||||
|
VM_IE, VM_IQ, VM_II
|
||||||
}
|
}
|
||||||
|
|
||||||
string rxGetString(int starting)
|
string rxGetString(int starting)
|
||||||
|
@ -273,6 +274,18 @@ namespace Nga
|
||||||
case OpCodes.VM_END:
|
case OpCodes.VM_END:
|
||||||
ip = 524288 * 16;
|
ip = 524288 * 16;
|
||||||
break;
|
break;
|
||||||
|
case OpCodes.VM_IE:
|
||||||
|
data[sp] = 1;
|
||||||
|
break;
|
||||||
|
case OpCodes.VM_IQ:
|
||||||
|
data[sp++] = 0;
|
||||||
|
data[sp] = 0;
|
||||||
|
break;
|
||||||
|
case OpCodes.VM_II:
|
||||||
|
sp--;
|
||||||
|
char c = (char)data[sp--];
|
||||||
|
Console.Write(c);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
ip = 524288 * 16;
|
ip = 524288 * 16;
|
||||||
break;
|
break;
|
||||||
|
@ -285,7 +298,7 @@ namespace Nga
|
||||||
int valid = -1;
|
int valid = -1;
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
current = raw & 0xFF;
|
current = raw & 0xFF;
|
||||||
if (!(current >= 0 && current <= 26))
|
if (!(current >= 0 && current <= 29))
|
||||||
valid = 0;
|
valid = 0;
|
||||||
raw = raw >> 8;
|
raw = raw >> 8;
|
||||||
}
|
}
|
||||||
|
@ -329,12 +342,7 @@ public void executeFunction(int cell) {
|
||||||
if (ngaValidatePackedOpcodes(opcode) != 0) {
|
if (ngaValidatePackedOpcodes(opcode) != 0) {
|
||||||
ngaProcessPackedOpcodes(opcode);
|
ngaProcessPackedOpcodes(opcode);
|
||||||
} else {
|
} else {
|
||||||
if (opcode == 1000) {
|
ngaProcessOpcode(opcode);
|
||||||
char c = (char)data[sp--];
|
|
||||||
Console.Write(c);
|
|
||||||
} else {
|
|
||||||
ngaProcessOpcode(opcode);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ip++;
|
ip++;
|
||||||
if (rsp == 0)
|
if (rsp == 0)
|
||||||
|
|
Loading…
Reference in a new issue