Updated make target for a2enh

This commit is contained in:
Luxferre
2022-08-14 15:58:45 +03:00
parent 132dcedc9e
commit 93f19d3a17
3 changed files with 28 additions and 16 deletions
+16 -11
View File
@@ -139,6 +139,9 @@ static uchar* flatram = (uchar *)&ram;
/* reference to the current task context */
static struct EquiCtx *curtask;
/* reference to the buffer task context */
static struct EquiCtx *taskptr;
/* Error reporting codes */
enum EquiErrors {
SUCCESS=0,
@@ -201,7 +204,10 @@ void trapout(errcode) {
cerr("All task slots busy and active\n");
break;
}
exit(errcode);
if(curtask) /* if we're in a task, only terminate it */
curtask->active=1;
else /* otherwise to a hard trapout */
exit(errcode);
}
}
@@ -257,7 +263,8 @@ enum EquiInstructions {
enum EquiPorts {
PORT_ECHO = 0x0, /* echo port, used for testing: R1=P1, R2=P2 */
PORT_RANDOM, /* RNG port: P1 = valueFrom, P2 = valueTo => R1=rand(from, to), R2 = rand(from, to) */
PORT_CHECKSUM /* checksum port: P1 = memAddr, P2 = length => R1=CRC16(memAddr, length), R2 = 0 */
PORT_CHECKSUM, /* checksum port: P1 = memAddr, P2 = length => R1=CRC16(memAddr, length), R2 = 0 */
PORT_TASKCTL /* task control port: P1 = task id, P2 = operation => R1 = operation result, R2 = operation status */
};
/* push a value onto the main stack */
@@ -393,7 +400,7 @@ void portIO(ushort port, ushort p2, ushort p1) {
r1 = crc16(&flatram[p1], p2);
break;
default:
fprintf(stderr, "[PORTIO] Unimplemented call to port 0x%X with P1=%X and P2=%X, returning status=0, R1=0, R2=0\n", port, p1, p2);
fprintf(stderr, "[PORTIO] Unimplemented call to port 0x%X with P1=%X and P2=%X\n", port, p1, p2);
}
pushMain(r1);
pushMain(r2);
@@ -432,7 +439,7 @@ struct EquiCtx* equi_load_task(uchar priv, ushort len, ushort progStart) {
/* don't allow to load privileged tasks from non-privileged ones */
if(curtask && !curtask->privileged)
priv = 0;
struct EquiCtx *taskptr = &ram.tasks[tid]; /* refer to the next available entry */
taskptr = &ram.tasks[tid]; /* refer to the next available entry */
taskptr->msp = taskptr->rsp = taskptr->lsp = taskptr->cltp = 0; /* init stacks and CLT */
taskptr->pc = progStart - 1U; /* init program counter for preincrement logic */
taskptr->cmd_start = progStart; /* actual command buffer start (from the start of vRAM) */
@@ -448,7 +455,6 @@ struct EquiCtx* equi_load_task(uchar priv, ushort len, ushort progStart) {
void equi_main_loop() {
uchar instr;
ushort lhash, pbuf, pbuf2;
struct EquiCtx *newtaskptr;
/* try to open the persistent sandbox file */
FILE *pfd = fopen(PERSIST_FILE, "r+b");
while(1) { /* iterate over the instructions in the command buffer */
@@ -664,9 +670,9 @@ void equi_main_loop() {
pushMain(persistOp(pfd, popMain(), popMain(), popMain(), 1));
break;
case INS_TASKLOAD: /* ( addr len priv -- taskid ) */
newtaskptr = equi_load_task(popMain(), popMain(), popMain());
newtaskptr->active = 1;
pushMain(newtaskptr->id);
taskptr = equi_load_task(popMain(), popMain(), popMain());
taskptr->active = 1;
pushMain(taskptr->id);
break;
default: /* all characters not processed before are invalid instructions */
trapout(INVALID_INSTRUCTION);
@@ -714,8 +720,7 @@ int main(int argc, char* argv[]) {
#else /* VT100-compatible terminal init */
printf("\033c");
#endif
printf("Welcome to Equi v" EQUI_VER " by Luxferre, 2022\nStack size: %d bytes\nLiteral stack size: %d bytes\nCommand buffer: 0x%04X (%d bytes)\nEqui ready\n\n> ",
STACK_SIZE, LIT_STACK_SIZE, ram.cmd_start, ram.cmd_size);
printf("Welcome to Equi v" EQUI_VER " by Luxferre, 2022\nSystem RAM: %d bytes\nEqui ready\n\n> ", (int) sizeof(ram));
}
while(1) { /* Now, we're in the command mode loop */
@@ -736,7 +741,7 @@ int main(int argc, char* argv[]) {
cputc(instr); /* echo it */
#endif
ram.II = 0;
} else if(!ram.II && (instr == 0xFFU || instr == INS_QUIT)) {
} else if(!ram.II && instr == INS_QUIT) {
if(ram.MM) { /* output command buffer contents to stdout and exit */
ram.cmdbuf[++ram.ibp] = INS_QUIT; /* end program with INS_QUIT */
ram.cmdbuf[++ram.ibp] = 0; /* and zero terminator */