diff options
-rw-r--r-- | asmmon.c | 23 | ||||
-rw-r--r-- | lexer.c | 21 | ||||
-rw-r--r-- | programs/subeditor.s | 2 | ||||
-rw-r--r-- | sux.c | 14 | ||||
-rw-r--r-- | test/asr.s | 3 | ||||
-rw-r--r-- | test/test-stack.s | 2 |
6 files changed, 16 insertions, 49 deletions
@@ -181,7 +181,6 @@ void list(uint16_t start, uint16_t end, uint8_t all, uint8_t ln, uint8_t addr, u } if (flags & 0x20) { printf("%s", symbols[tokline[i].sym]->name); - /*get_symname(tokline[i].sym, 0));*/ if (tokline[i].islabel) { printf(": "); } else if (tokline[i].issym) { @@ -363,13 +362,11 @@ uint64_t assemble(uint8_t dbg) { opsize = 0; skip = 0; if ((flags & 0x53) == 0x42) { - /*value = use_symbol("", symid, tmpaddr, 1, 0);*/ value = symbols[symid]->val; } else { value = tokline[i].op; } if ((flags & 0x51) == 0x41) { - /*value = use_symbol("", symid, tmpaddr, 1, 0);*/ value = symbols[symid]->val; } if (flags & 0x220) { @@ -583,23 +580,19 @@ int asmmon(const char *fn) { uint8_t dbg = 0; init_symbol(); while (!done) { - /*char *buf = NULL;*/ char *cmd; char *arg = malloc(sizeof(char *)*128); char *tmp = malloc(sizeof(char *)*128); - char *lex_line = NULL; - size_t size; - ssize_t line_len; + char lex_line[0x1000]; + uint16_t size = 0; uint8_t cmds = 0; - /* Is shortend command. */ + uint8_t dummy = 0; + /* Is single character command. */ uint8_t isshcmd = 0; - if (!strcasecmp(fn, "stdin")) { - line_len = getline(&lex_line, &size, stdin); - } else { - line_len = getline(&lex_line, &size, fp); - } - cmd = malloc(sizeof(char *)*(line_len+1)); - memcpy(cmd, lex_line, line_len+1); + fgets(lex_line, sizeof(lex_line), (!strcasecmp(fn, "stdin")) ? stdin : fp); + size = strlen(lex_line)+1; + cmd = malloc(size); + memcpy(cmd, lex_line, size); cmd = strtok_r(cmd, " \t\n", &tmp); if (cmd != NULL) { isshcmd = (cmd[1] == '\0' || cmd[1] == ' '); @@ -107,7 +107,6 @@ uint8_t set_symval(const char *name, uint16_t id, uint64_t val, uint8_t useid, u } char *get_symname(uint16_t id, uint8_t dbg) { - /*struct symbol *s = mksymbol("", 0, 0, 1, id, dbg);*/ if (symbols[id]->def) { return symbols[id]->name; } else { @@ -208,28 +207,11 @@ uint16_t get_string(const char *str, uint8_t dbg) { uint16_t reslv_fixups(uint8_t dbg) { uint16_t i = 0, j = 0; for (; fixups[j]; j++) { - /*printf("f: $%016"PRIX64", f->nxt: $%016"PRIX64", f->s->name: %s, f->s->val: $%016"PRIX64"\n", &f, &f->nxt, f->s->name, f->s->val);*/ if (fixups[j]->s->def) { if (dbg) { printf("reslv_fixups(): Symbol ID: $%X, Symbol Name: %s.\n", fixups[j]->s->id, fixups[j]->s->name); } tokline[fixups[j]->ln].sym = fixups[j]->s->id; - /*if (f->ln == 0xFFFF) { - addr[f->adr] = f->s->val & 0xFF; - if (f->s->val & 0xFF00) - addr[f->adr+1] = f->s->val >> 8; - if (f->s->val & 0xFF000000) { - addr[f->adr+2] = f->s->val >> 16; - addr[f->adr+3] = f->s->val >> 24; - } - if (f->s->val & 0xFF00000000000000) { - addr[f->adr+4] = f->s->val >> 32; - addr[f->adr+5] = f->s->val >> 40; - addr[f->adr+6] = f->s->val >> 48; - addr[f->adr+7] = f->s->val >> 56; - } - } else { - }*/ } else { if (dbg) { printf("reslv_fixups(): oof, undefined reference to '%s', at $%016"PRIX64".\n", fixups[j]->s->name, fixups[j]->adr); @@ -293,7 +275,6 @@ uint64_t update_addr(uint64_t address, uint8_t fixup, uint16_t l, uint8_t dbg) { value = 0; } else { value = use_symbol("", symid, address, 1, dbg); - /*value = symbols[symid]->val;*/ } } else { value = tokline[l].op; @@ -390,7 +371,6 @@ uint64_t update_addr(uint64_t address, uint8_t fixup, uint16_t l, uint8_t dbg) { printf("update_addr(): "); puts("Addressing Mode has been set to Zero Matrix."); } - /*address += !(opsize-1);*/ } break; case 1: @@ -897,7 +877,6 @@ uint64_t lex(char *str, uint64_t address, uint8_t dbg) { printf("lex(): lexeme: %s, lex_type: %s\n", lexeme, (lex_type != 0xFF) ? lex_tok[lex_type] : "TOK_NONE"); } isstart = 0; - /*lex_type = 0xFF;*/ j = 0; if (lex_type == TOK_OPCODE && !isop) { j = 0; diff --git a/programs/subeditor.s b/programs/subeditor.s index fddc729..8eec46a 100644 --- a/programs/subeditor.s +++ b/programs/subeditor.s @@ -1179,5 +1179,5 @@ rdrwln_done: .org $FFC0 .qword reset a -done +d @@ -36,7 +36,6 @@ uint64_t inss; uint8_t threads_done = 0; uint8_t kbd_rdy = 0; uint8_t step = 0; -uint8_t irq = 0; #if !bench @@ -64,7 +63,6 @@ void *run(void *args) { uint64_t address = 0; uint8_t prefix = 0; uint8_t opcode = 0; - uint8_t end = 0; uint64_t sum = 0; uint64_t value = 0; uint64_t reg = 0; @@ -72,7 +70,7 @@ void *run(void *args) { uint64_t iclk = 0; #endif uint64_t ins = 0; - uint64_t sign = 0; + uint8_t sign = 0; uint8_t tmp; uint8_t tmp2; #if !bench @@ -99,7 +97,7 @@ void *run(void *args) { pthread_mutex_unlock(&mutex); #endif #endif - while (!end) { + for (;;) { address = 0; prefix = addr[cpu->pc[thread]]; if ((prefix & 0x03) != 0x03) { @@ -130,13 +128,9 @@ void *run(void *args) { wprintw(scr, ", sp: $%04X" ", ps: $%02"PRIX64 - /*", prefix: $%02X" - ", opcode: $%02X"*/ ", inst: " , cpu->sp[thread] , cpu->ps); - /*, prefix - , opcode);*/ #if keypoll pthread_mutex_unlock(&mutex); #endif @@ -855,7 +849,7 @@ void *run(void *args) { case ASR_AB: /* ASR Absolute. */ case ASR_Z: /* ASR Zero Matrix. */ sign = cpu->a[thread] >> 63; - sum = (value < 64) ? (cpu->a[thread] >> value) | sign : 0; + sum = (value < 64) ? (cpu->a[thread] >> value) | ((uint64_t)sign << 63) : 0; setflag(sum == 0, Z); setflag(sum >> 63, N); setflag(cpu->a[thread] & 1, C); @@ -1258,7 +1252,6 @@ void *run(void *args) { #endif #elif bench if (ins >= BENCH_INST) { - end = 1; pthread_mutex_lock(&main_mutex); threads_done++; inst[thread] = ins; @@ -1268,6 +1261,7 @@ void *run(void *args) { pthread_cond_signal(&main_cond); pthread_mutex_unlock(&main_mutex); gettimeofday(&en[thread], 0); + break; } #endif } @@ -5,8 +5,9 @@ reset: cps start: + clc lda #0 - sbc #$FFFF + sbc.w #$FFFF ldb #0 deb signshft: diff --git a/test/test-stack.s b/test/test-stack.s index b9218a0..a63f54a 100644 --- a/test/test-stack.s +++ b/test/test-stack.s @@ -2,7 +2,7 @@ init: cps ldx.w #$FFFF txs - + tax loop: inc pha #1 |