diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2019-12-14 23:58:01 -0500 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2019-12-14 23:58:01 -0500 |
commit | 0b81224b6ab8cd6da45039525962c6490ed2df56 (patch) | |
tree | a76bfa10ee6ae726efb212442a68c17b253b49ba /asmmon.c | |
parent | c6d71bcf0e545a490fdeb0dfcafea2d5a02157c6 (diff) |
We now have keyboard support!!!
I also added the WAI instruction, which puts the thread
that executed it, into a catatonic stat, where it can't
do anything, until an interrupt occurs.
I will be starting work on GFsuX next.
I also might start work on SuBAsm, the
Sux Bootstrapping Assembler.
Diffstat (limited to 'asmmon.c')
-rw-r--r-- | asmmon.c | 25 |
1 files changed, 18 insertions, 7 deletions
@@ -4,7 +4,7 @@ #define debug 1 -#define OPNUM 88 +#define OPNUM 89 #define SETOP(num, _mne, _IMM, _ZM, _ZMX, _ZMY, _ABS, _IMPL) \ {opcodes[num].mnemonic[3] = '\0'; strncpy(opcodes[num].mnemonic, _mne, 3); \ opcodes[num].imm = _IMM; \ @@ -123,7 +123,7 @@ void viewmem(uint64_t address) { printf("\n"); } } -int asmmon() { +int asmmon(const char *fn) { opent opcodes[OPNUM]; /* mne IMM ZM ZMX ZMY ABS IMPL*/ SETOP(0, "CPS", 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); @@ -210,10 +210,17 @@ int asmmon() { SETOP(81, "DAY", 0x00, 0xF3, 0x00, 0x00, 0xF1, 0xD3); SETOP(82, "DEX", 0x00, 0x00, 0x00, 0x00, 0x00, 0xD4); SETOP(83, "DAX", 0x00, 0x00, 0x00, 0x00, 0x00, 0xD5); - SETOP(84, "JSL", 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00); - SETOP(85, "NOP", 0x00, 0x00, 0x00, 0x00, 0x00, 0xE8); - SETOP(86, "RTL", 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0); - SETOP(87, "BRK", 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8); + SETOP(84, "WAI", 0x00, 0x00, 0x00, 0x00, 0x00, 0xD8); + SETOP(85, "JSL", 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00); + SETOP(86, "NOP", 0x00, 0x00, 0x00, 0x00, 0x00, 0xE8); + SETOP(87, "RTL", 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0); + SETOP(88, "BRK", 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8); + FILE *fp; + if (strcasecmp(fn, "stdin") != 0) { + fp = fopen(fn, "r"); + if (fp == NULL) + return 2; + } uint8_t done = 0; uint64_t address = 0x0000; while (!(done & 1)) { @@ -231,7 +238,11 @@ int asmmon() { char *tmp = malloc(sizeof(char *)*128); size_t size; done &= ~0x1F; - getline(&buf, &size, stdin); + if (!strcasecmp(fn, "stdin")) { + getline(&buf, &size, stdin); + } else { + getline(&buf, &size, fp); + } cmd = strtok_r(buf, "\n", &tmp); if (cmd != NULL) { if (strcasecmp(cmd, "done") == 0) { |