src/emcalls.c
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
/* emcalls.c: This file implements emulator calls ("emcalls"). Emcalls are
analogous to system calls, except since there's no real OS, they're handled
directly by the emulator. The basic usage should revolve around adding cases
to the emcall switch-case, where each case is a special emcall that calls a
function to handle it. This is perhaps the easiest way to plug fancy features
into the emulator itself; basically treat the EMC instruction is like the ioctl
syscall (_now_ I see why ioctl is such a tempting serpent of a syscall to have)
x1phosura 2021
*/
#include <stdint.h>
#include <stdio.h>
void do_emcall(uint8_t emc_args[2])
{
// emc_args[1] may be used in the future
switch(emc_args[0]) {
case 0x00:
printf("I'm a zero emcall!\n"); // replace with emcall handler
break;
case 0x01:
printf("I'm a one emcall!\n"); // replace with emcall handler
break;
case 0x02:
printf("I'm a two emcall!\n"); // replace with emcall handler
break;
default:
printf("EMC: 1st arg: 0x%02x, 2nd arg: 0x%02x\n", emc_args[0], emc_args[1]);
}
printf("[DEBUG] TODO: finish (stubbed)\n");
}
|