From: j8takagi Date: Thu, 21 Jan 2010 14:18:23 +0000 (+0900) Subject: dumpwordコマンドを追加 X-Git-Tag: v0.1~85 X-Git-Url: https://j8takagi.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fd17e19672d6df5bdde0568e29ef7c462429735c;p=YACASL2.git dumpwordコマンドを追加 dumpwordは、16進数値を10進/2進数値として表示する --- diff --git a/include/casl2.h b/include/casl2.h index 47461dc..65d2870 100644 --- a/include/casl2.h +++ b/include/casl2.h @@ -155,3 +155,12 @@ void freecerr(); /* 指定されたファイルにアセンブル結果を書込 */ void outassemble(char *file); + +/* WORD値を2進数表記に変換 */ +char *word2bit(const WORD word); + +/* COMET IIのメモリを表示 */ +void dumpmemory(); + +/* COMET IIのレジスタを表示 */ +void dspregister(); diff --git a/include/exec.h b/include/exec.h index 529702c..c06929f 100644 --- a/include/exec.h +++ b/include/exec.h @@ -52,12 +52,3 @@ void reset(); /* コードの実行 */ void exec(); - -/* WORD値を2進数表記に変換 */ -char *word2bit(const WORD word); - -/* COMET IIのメモリを表示 */ -void dumpmemory(); - -/* COMET IIのレジスタを表示 */ -void dspregister(); diff --git a/src/Makefile b/src/Makefile index eab8363..0ff70c2 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,23 +1,23 @@ INCLUDE = ../include CC = gcc -CFLAGS = -g -Wall -I $(INCLUDE) -COMMONSRC = struct.o cmd.o cerr.o +CFLAGS = -Wall -I $(INCLUDE) +COMMONSRC = struct.o cmd.o cerr.o dump.o ASSRC = assemble.o token.o label.o macro.o -EXECSRC = exec.o dump.o +EXECSRC = exec.o .PHPNY: all clean -all: ../casl2 ../comet2 TAGS +all: ../casl2 ../comet2 ../dumpword TAGS ../casl2: casl2.o $(COMMONSRC) $(ASSRC) $(EXECSRC) $(CC) $(CFLAGS) -o $@ $^ ../comet2: comet2.o $(COMMONSRC) $(EXECSRC) $(CC) $(CFLAGS) -o $@ $^ +../dumpword: dumpword.o $(COMMONSRC) + $(CC) $(CFLAGS) -o $@ $^ %.o: %.c $(CC) -c $(CFLAGS) $< casl2.o comet2.o $(COMMONSRC) $(ASSRC) $(EXECSRC): $(INCLUDE)/casl2.h casl2.o $(ASSRC): $(INCLUDE)/assemble.h -comet2.c $(EXECSRC): $(INCLUDE)/exec.h +comet2.o $(EXECSRC): $(INCLUDE)/exec.h TAGS: $(INCLUDE)/*.h *.c - @if test `which etags`; then \ - etags $^; \ - fi + @if test `which etags`; then etags $^; fi clean: @rm -f *.o diff --git a/src/casl2.c b/src/casl2.c index f4c8f88..ad07960 100644 --- a/src/casl2.c +++ b/src/casl2.c @@ -101,7 +101,7 @@ int main(int argc, char *argv[]) } } if(argv[optind] == NULL) { - fprintf(stderr, "source file is not specified\n"); + fprintf(stderr, "source file is not specified\n"); exit(-1); } /* ソースファイルが指定されていない場合は終了 */ diff --git a/src/dump.c b/src/dump.c index 2c77520..d07c40f 100644 --- a/src/dump.c +++ b/src/dump.c @@ -1,5 +1,4 @@ #include "casl2.h" -#include "exec.h" /* WORD値を2進数表記に変換 */ char *word2bit(const WORD word) @@ -8,8 +7,8 @@ char *word2bit(const WORD word) char *bit, *p; bit = malloc(16 + 1); p = bit; - while(mask > 0){ - if((word & mask) == 0) { + while(mask > 0){ + if((word & mask) == 0) { *p++ = '0'; } else { *p++ = '1'; @@ -32,7 +31,7 @@ void dumpmemory() } fprintf(stdout, "\n"); /* Memory */ - for(i = 0; i < MEMSIZE; i++) { + for(i = 0; i < memsize; i++) { if(i % col == 0) { fprintf(stdout, "#%04X: %04X: ", PR, i); } diff --git a/src/exec.c b/src/exec.c index 25d6c38..4b3ed78 100644 --- a/src/exec.c +++ b/src/exec.c @@ -42,7 +42,8 @@ void svcout() } /* 「文字の組」の符号表に記載された文字と、改行(CR)/タブを表示 それ以外の文字は、「.」で表す */ - if(((c = (char)(memory[GR[1]+i])) >= 0x20 && c <= 0x7E) || c == 0xA || c == '\t') { + if(((c = (char)(memory[GR[1]+i])) >= 0x20 && c <= 0x7E) || c == 0xA || c == '\t') + { putchar(c); } else { putchar('.');