# ソースファイル。グループに分類
-CMDOBJ := casl2 comet2 dumpword disassemble
+CMDOBJ := casl2 comet2 dumpword casl2rev
COMMONOBJ := word cmem cerr
CASL2OBJ := struct hash
ASOBJ := assemble token label
dumpword: $(addsuffix .o,dumpword $(COMMONOBJ))
-disassemble:$(addsuffix .o,disassemble $(COMMONOBJ) $(CASL2OBJ) $(EXECOBJ))
+casl2rev:$(addsuffix .o,casl2rev $(COMMONOBJ) $(CASL2OBJ) $(EXECOBJ))
# .dファイルからヘッダファイルの依存関係を取得する
# tags、check、clean、.d で終わるターゲットの場合は除く
#include <stdio.h>
#include <stdlib.h>
+
#define _GNU_SOURCE
#include <getopt.h>
#include <assert.h>
char *grstr(WORD word)
{
+ assert(word <= 7);
char *str = malloc_chk(3 + 1, "grstr.str");
sprintf(str, "GR%d", word);
return str;
FILE *fp;
WORD i = 0, w, cmd, r, x, r1, r2, adr;
CMDTYPE cmdtype = 0;
- char *cmdname, *g1, *g2;
+ char *cmdname;
assert(file != NULL);
if((fp = fopen(file, "rb")) == NULL) {
fprintf(stdout, "\t%s\t", cmdname);
if(cmdtype == R_ADR_X) {
r = (w & 0x00F0) >> 4;
- fprintf(stdout, "%s,", (g1 = grstr(r)));
- FREE(g1);
+ fprintf(stdout, "%s,", grstr(r));
}
fprintf(stdout, "#%04X", adr);
if((x = w & 0x000F) != 0) {
- fprintf(stdout, ",%s", (g1 = grstr(x)));
- FREE(g1);
+ fprintf(stdout, ",%s", grstr(x));
}
fprintf(stdout, "\t\t\t\t; #%04X: #%04X #%04X", i, w, adr);
i += 2;
if(cmdtype == R1_R2) {
r1 = (w & 0x00F0) >> 4;
r2 = w & 0x000F;
- fprintf(stdout, "\t%s,%s", (g1=grstr(r1)), (g2=grstr(r2)));
- FREE(g1);
- FREE(g2);
+ fprintf(stdout, "\t%s,%s", grstr(r1), grstr(r2));
} else if(cmdtype == R_) {
r = (w & 0x00F0) >> 4;
- fprintf(stdout, "\t%s", (g1 = grstr(r)));
- FREE(g1);
+ fprintf(stdout, "\t%s", grstr(r));
}
fprintf(stdout, "\t\t\t\t; #%04X: #%04X", i++, w);
}
--- /dev/null
+MAIN START
+ PUSH #0000,GR1 ; #0000: #7001 #0000
+ LAD GR0,#0000 ; #0002: #1200 #0000
+ LD GR1,#0011 ; #0004: #1010 #0011
+ ADDL GR0,GR1 ; #0006: #2601
+ ADDL GR1,#0013 ; #0007: #2210 #0013
+ CPL GR1,#0012 ; #0009: #4110 #0012
+ JPL #000F ; #000B: #6500 #000F
+ JUMP #0006 ; #000D: #6400 #0006
+ POP GR1 ; #000F: #7110
+ RET ; #0010: #8100
+ DC 1 ; #0011: #0001 :: 1 = #0001 = 0000000000000001
+ DC 10 ; #0012: #000A :: 10 = #000A = 0000000000001010 = '\n'
+ DC 1 ; #0013: #0001 :: 1 = #0001 = 0000000000000001
+ END