all:
make -C src
check:
- make -sC test/integration
+ @make -sC test/integration
clean:
@for target in $(CLEANDIR); do $(MAKE) -sC $$target clean; done
install: all
+#ifndef YACASL2_ASSEMBLE_INCLUDED
+#define YACASL2_ASSEMBLE_INCLUDED
+
/* CASL IIの制限 */
enum {
LINESIZE = 1024, /* 行の最大文字数 */
/* マクロ命令「RPOP」をメモリに書込 */
bool writeRPOP(PASS pass);
+
+#endif
+#ifndef YACASL2_CASL2_INCLUDED
+#define YACASL2_CASL2_INCLUDED
+
#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <malloc.h>
-#include <ctype.h>
-#include <assert.h>
#include <stdbool.h>
#include <time.h>
+#include <assert.h>
+#include <ctype.h>
+#include <string.h>
+
+#include "word.h"
#include "hash.h"
+#include "cerr.h"
+#ifndef ARRAYSIZE
#define ARRAYSIZE(array) (sizeof(array)/sizeof(array[0]))
+#endif
/* COMET IIの規格 */
enum {
DEFAULT_CLOCKS = 5000000, /* デフォルトのクロック周波数。COMET II規格では、未定義 */
};
-/* COMET IIの基本データサイズ */
-typedef unsigned short WORD;
-
/* COMET IIのメモリ */
extern WORD *memory;
ZF = 0x1, /* Zero Flag */
};
-/* エラー番号 */
-extern int cerrno;
-
-/* エラーメッセージ */
-extern char *cerrmsg;
-
/* レジストリの内容を表示する場合はTRUE */
extern bool tracemode;
/* 命令コードがキーのハッシュ表を解放する */
void free_code_type();
-/* エラー番号とエラーメッセージを設定 */
-void setcerr(int num, const char *val);
-
-/* エラー番号からメッセージを返す */
-char *getcerrmsg(int num);
-
-/* WORD値を文字列に変換 */
-char *wtoa(WORD word);
-
-/* エラーを解放する */
-void freecerr();
-
/* 指定されたファイルにアセンブル結果を書込 */
void outassemble(char *file);
-/* WORD値を2進数表記に変換 */
-char *word2bit(const WORD word);
-
-/* COMET IIのメモリを表示 */
-void dumpmemory();
-
-/* COMET IIのレジスタを表示 */
-void dspregister();
+#endif
--- /dev/null
+#ifndef YACASL2_CERR_H_INCLUDED
+#define YACASL2_CERR_H_INCLUDED
+
+#include <malloc.h>
+#include <string.h>
+#include <assert.h>
+
+#ifndef ARRAYSIZE
+#define ARRAYSIZE(array) (sizeof(array)/sizeof(array[0]))
+#endif
+
+/* エラー番号 */
+extern int cerrno;
+
+/* エラーメッセージ */
+extern char *cerrmsg;
+
+/* エラーコードリスト */
+typedef struct {
+ int num;
+ char *msg;
+} CERRARRAY;
+
+/* エラー番号とエラーメッセージを設定 */
+void setcerr(int num, const char *val);
+
+/* エラー番号からメッセージを返す */
+char *getcerrmsg(int num);
+
+/* エラーを解放する */
+void freecerr();
+#endif
+#ifndef YACASL2_EXEC_INCLUDED
+#define YACASL2_EXEC_INCLUDED
+
/* コードから命令のパターンを取得 */
CMDTYPE getcmdtype(WORD code);
/* コードの実行 */
void exec();
+
+/* COMET IIのメモリを表示 */
+void dumpmemory();
+
+/* COMET IIのレジスタを表示 */
+void dspregister();
+
+#endif
+#ifndef YACASL2_HASH_INCLUDED
+#define YACASL2_HASH_INCLUDED
+
/* ハッシュ共用体の型 */
typedef enum {
CHARS = 0,
/* ハッシュ値を取得する */
unsigned hash(int keyc, HKEY *keyv[], int tabsize);
+
+#endif
--- /dev/null
+#ifndef YACASL2_WORD_H_INCLUDED
+#define YACASL2_WORD_H_INCLUDED
+
+#include <string.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include "cerr.h"
+
+/* WORD - 16ビットデータ型 */
+typedef unsigned short WORD;
+
+/* 10進数の文字列をWORD値に変換 */
+WORD n2word(const char *str);
+
+/* 16進数の文字列をWORD値に変換 */
+WORD h2word(const char *str);
+
+/* 10進数または16進数の文字列をWORD値に変換 */
+WORD a2word(const char *str);
+
+/* WORD値を10進数の文字列に変換 */
+char *word2n(WORD word);
+
+/* WORD値を2進数の文字列に変換 */
+char *word2bit(const WORD word);
+
+#endif
INCLUDE = ../include
CC = gcc
CFLAGS = -g -Wall -I $(INCLUDE)
-COMMONSRC = struct.o hash.o cmd.o cerr.o dump.o
+COMMONSRC = word.o struct.o hash.o cmd.o cerr.o
ASSRC = assemble.o token.o label.o macro.o
-EXECSRC = exec.o
+EXECSRC = exec.o dump.o
.PHPNY: all clean
all: ../casl2 ../comet2 ../dumpword TAGS
../casl2: casl2.o $(COMMONSRC) $(ASSRC) $(EXECSRC)
$(CC) $(CFLAGS) -o $@ $^
%.o: %.c
$(CC) -c $(CFLAGS) $<
-casl2.o comet2.o $(COMMONSRC) $(ASSRC) $(EXECSRC): $(INCLUDE)/casl2.h $(INCLUDE)/hash.h
+casl2.o comet2.o $(COMMONSRC) $(ASSRC) $(EXECSRC): $(INCLUDE)/casl2.h $(INCLUDE)/word.h $(INCLUDE)/hash.h $(INCLUDE)/cerr.h
casl2.o $(ASSRC): $(INCLUDE)/assemble.h
comet2.o $(EXECSRC): $(INCLUDE)/exec.h
TAGS: $(INCLUDE)/*.h *.c
/* 他のプログラムで参照する入口名 */
char *prog;
-/* 汎用レジスタを表す文字列「GR[0-7]」をWORD値に変換
- is_xがtrueの場合は、指標レジスタとして用いる汎用レジスタ
- 文字列が汎用レジスタを表さない場合は、0xFFFFを返す */
+/* 汎用レジスタを表す文字列「GR[0-7]」をWORD値に変換 */
+/* is_xがtrueの場合は、指標レジスタとして用いる汎用レジスタ */
+/* 文字列が汎用レジスタを表さない場合は、0xFFFFを返す */
WORD getgr(const char *str, bool is_x)
{
assert(str != NULL);
return r;
}
-/* 10進定数をWORD値に変換 */
-WORD getint(const char *str)
-{
- assert(isdigit(*str) || *str == '-');
- char *check;
- int n;
- /* WORD値に変換 */
- n = strtol(str, &check, 10);
- if(*check != '\0') {
- setcerr(114, str); /* not integer */
- return 0x0;
- }
- /* nが-32768〜32767の範囲にないときは、その下位16ビットを格納 */
- if(n < -32768 || n > 32767) {
- n = n % 32768;
- }
- return (WORD)n;
-}
-
-/* 16進定数をWORD値に変換 */
-WORD gethex(const char *str)
-{
- assert(*str == '#');
- WORD adr = 0x0;
- char *check;
- str++;
- if(*str == '-' || strlen(str) > 4) {
- setcerr(116, str-1); /* out of hex range */
- return 0;
- }
- /* WORD値に変換 */
- adr = (WORD)strtol(str, &check, 16);
- if(*check != '\0') {
- setcerr(115, str-1); /* not hex */
- return 0x0;
- }
- return adr;
-}
-
-/* アドレスを返す
- アドレスには、リテラル/10進定数/16進定数/アドレス定数が含まれる */
+/* アドレスを返す */
+/* アドレスには、リテラル/10進定数/16進定数/アドレス定数が含まれる */
WORD getadr(const char *prog, const char *str, PASS pass)
{
WORD adr = 0x0;
if(*str == '=') {
adr = getliteral(str, pass);
- } else if(*str == '#') {
- adr = gethex(str);
- } else if(isdigit(*str) || *str == '-') {
- adr = getint(str);
+ } else if((*str == '#') || isdigit(*str) || *str == '-') {
+ adr = a2word(str);
} else {
if(pass == SECOND && (adr = getlabel(prog, str)) == 0xFFFF) {
if(prog != NULL) {
return adr;
}
-/* WORD値wordをアドレスadrに書込
- 書込に成功した場合はtrue、失敗した場合はfalseを返す */
+/* WORD値wordをアドレスadrに書込 */
+/* 書込に成功した場合はtrue、失敗した場合はfalseを返す */
bool writememory(WORD word, WORD adr, PASS pass)
{
bool status = false;
/* COMET IIメモリオーバーの場合 */
if(adr >= memsize) {
- setcerr(119, wtoa(adr)); /* out of COMET II memory */
+ setcerr(119, word2n(adr)); /* out of COMET II memory */
}
if(cerrno == 0) {
memory[adr] = word;
/* リテラルには、10進定数/16進定数/文字定数が含まれる */
WORD getliteral(const char *str, PASS pass)
{
- WORD adr = lptr, word = 0x0;
+ WORD adr = lptr;
assert(*str == '=');
str++;
if(*str == '\'') { /* 文字定数 */
writestr(str, true, pass);
} else {
- if(*str == '#') { /* 16進定数 */
- word = gethex(str);
- } else if(isdigit(*str) || *str == '-') { /* 10進定数 */
- word = getint(str);
- }
- /* リテラル領域に書込 */
- writememory(word, lptr++, pass);
+ writememory(a2word(str), lptr++, pass);
}
return adr;
}
if(*str == '\'') {
writestr(str, false, pass);
} else {
- if(*str == '#') {
- adr = gethex(str);
- } else if(isdigit(*str) || *str == '-') {
- adr = getint(str);
+ if(*str == '#' || isdigit(*str) || *str == '-') {
+ adr = a2word(str);
} else {
if(pass == SECOND && (adr = getlabel(prog, str)) == 0xFFFF) {
setcerr(103, str); /* label not found */
}
}
-/* 命令がアセンブラ命令の場合は処理を実行
- 実行に成功した場合はtrue、それ以外の場合はfalseを返す */
+/* 命令がアセンブラ命令の場合は処理を実行 */
+/* 実行に成功した場合はtrue、それ以外の場合はfalseを返す */
bool assemblecmd(const CMDLINE *cmdl, PASS pass)
{
int i = 0;
return status;
}
-/* 命令がマクロ命令の場合はメモリに書込
- 書込に成功した場合はtrue、それ以外の場合はfalseを返す */
+/* 命令がマクロ命令の場合はメモリに書込 */
+/* 書込に成功した場合はtrue、それ以外の場合はfalseを返す */
bool macrocmd(const CMDLINE *cmdl, PASS pass)
{
int i = 0;
return status;
}
-/* 機械語命令の書込
- 書込に成功した場合はtrue、それ以外の場合はfalseを返す */
+/* 機械語命令の書込 */
+/* 書込に成功した場合はtrue、それ以外の場合はfalseを返す */
bool cometcmd(const CMDLINE *cmdl, PASS pass)
{
WORD cmd, adr, r1, r2, x;
}
/* オペランド数2〜3。第2オペランドはアドレス、
第3オペランドは指標レジスタとして用いる汎用レジスタ */
- else if(cmdl->opd->opdc == 2 || cmdl->opd->opdc == 3)
- {
+ else if(cmdl->opd->opdc == 2 || cmdl->opd->opdc == 3) {
if((cmd = getcmdcode(cmdl->cmd, R_ADR_X_)) == 0xFFFF &&
(cmd = getcmdcode(cmdl->cmd, R_ADR_X)) == 0xFFFF)
{
-#include "casl2.h"
+#include "cerr.h"
-/* エラーコードリスト */
-typedef struct {
- int num;
- char *msg;
-} CERRARRAY;
CERRARRAY cerr[] = {
{ 101, "label already defined" },
{ 102, "label table is full" },
{ 207, "Stack Pointer (SP) - out of COMET II memory" },
};
-/* WORD値を文字列に変換 */
-char *wtoa(WORD word)
-{
- char *p = malloc(6), *q = malloc(6);
- int i = 0, j;
- do{
- *(p + i++) = word % 10 + '0';
- } while((word /= 10) > 0);
- for(j = 0; j < i; j++) {
- *(q + j) = *(p + (i - 1) - j);
- }
- *(q + j + 1) = '\0';
- return q;
-}
-
/* エラー番号とエラーメッセージを設定する */
void setcerr(int num, const char *val)
{
#include "casl2.h"
-/* WORD値を2進数表記に変換 */
-char *word2bit(const WORD word)
-{
- WORD mask = 0x8000;
- char *bit, *p;
- bit = malloc(16 + 1);
- p = bit;
- do {
- *p++ = (word & mask) ? '1' : '0';
- } while((mask >>= 1) > 0);
- *p = '\0';
- return bit;
-}
-
/* COMET IIのメモリを表示 */
void dumpmemory()
{
{"arithmetic", no_argument, NULL, 'a'},
{"logical", no_argument, NULL, 'l'},
{"help", no_argument, NULL, 'h'},
- {0, 0, 0, 0}
+ {0, 0, 0, 0},
};
int main(int argc, char *argv[])
{
int opt;
- WORD w;
- char *check;
+ WORD word;
const char *usage = "Usage: %s [-alh] WORD\n";
logicalmode = false;
break;
case 'h':
fprintf(stdout, usage, argv[0]);
- exit(-1);
+ return 0;
case '?':
fprintf(stderr, usage, argv[0]);
exit(-1);
fprintf(stderr, usage, argv[0]);
exit(-1);
}
- if(*argv[optind] == '-' || strlen(argv[optind]) > 4) {
- setcerr(116, argv[optind]); /* out of hex range */
- }
/* WORD値に変換 */
- w = (WORD)strtol(argv[optind], &check, 16);
- if(*check != '\0') {
- setcerr(115, argv[optind]); /* not hex */
- }
+ word = a2word(argv[optind]);
if(cerrno > 0) {
fprintf(stderr, "Dumpword Error - %d: %s\n", cerrno, cerrmsg);
exit(-1);
}
if(logicalmode == true) {
- fprintf(stdout, "%4s: %6d = #%04X = %s\n", argv[optind], w, w, word2bit(w));
+ fprintf(stdout, "%6s: %6d = #%04X = %s\n", argv[optind], word, word, word2bit(word));
} else {
- fprintf(stdout, "%4s: %6d = #%04X = %s\n", argv[optind], (short)w, w, word2bit(w));
+ fprintf(stdout, "%6s: %6d = #%04X = %s\n", argv[optind], (short)word, word, word2bit(word));
}
return 0;
}
--- /dev/null
+#include "word.h"
+
+/* 10進数の文字列をWORD値に変換 */
+WORD n2word(const char *str)
+{
+ assert(isdigit(*str) || *str == '-');
+ char *check;
+ int n;
+ /* WORD値に変換 */
+ n = strtol(str, &check, 10);
+ if(*check != '\0') {
+ setcerr(114, str); /* not integer */
+ return 0x0;
+ }
+ /* nが-32768〜32767の範囲にないときは、その下位16ビットを格納 */
+ if(n < -32768 || n > 32767) {
+ n = n % 0x10000;
+ }
+ return (WORD)n;
+}
+
+/* 16進数の文字列をWORD値に変換 */
+WORD h2word(const char *str)
+{
+ assert(*str == '#');
+ WORD w = 0x0;
+ char *check;
+ str++;
+ if(*str == '-' || strlen(str) > 4) {
+ setcerr(116, str-1); /* out of hex range */
+ return 0;
+ }
+ /* WORD値に変換 */
+ w = (WORD)strtol(str, &check, 16);
+ if(*check != '\0') {
+ setcerr(115, str-1); /* not hex */
+ return 0x0;
+ }
+ return w;
+}
+
+/* 10進数または16進数の文字列をWORD値に変換 */
+WORD a2word(const char *str)
+{
+ WORD word = 0x0;
+ if(*str == '#') {
+ word = h2word(str);
+ } else if(isdigit(*str) || *str == '-') {
+ word = n2word(str);
+ }
+ return word;
+}
+
+/* WORD値を10進数の文字列に変換 */
+char *word2n(WORD word)
+{
+ char *p = malloc(6), *q = malloc(6);
+ int i = 0, j;
+ do{
+ *(p + i++) = word % 10 + '0';
+ } while((word /= 10) > 0);
+ for(j = 0; j < i; j++) {
+ *(q + j) = *(p + (i - 1) - j);
+ }
+ *(q + j + 1) = '\0';
+ return q;
+}
+
+/* WORD値を2進数の文字列に変換 */
+char *word2bit(const WORD word)
+{
+ WORD mask = 0x8000;
+ char *bit, *p;
+ bit = malloc(16 + 1);
+ p = bit;
+ do {
+ *p++ = (word & mask) ? '1' : '0';
+ } while((mask >>= 1) > 0);
+ *p = '\0';
+ return bit;
+}
../../../../as/CMD/dc_overflow.casl: 6: RET
#0006 #8100
../../../../as/CMD/dc_overflow.casl: 7:A DC 32779
- #0007 #000B
+ #0007 #800B
../../../../as/CMD/dc_overflow.casl: 8:B DC 32778
- #0008 #000A
+ #0008 #800A
../../../../as/CMD/dc_overflow.casl: 9:C DS 1
#0009 #0000
../../../../as/CMD/dc_overflow.casl: 10: END
#0000: FR (OF SF ZF): 000
#0000: Memory::::
#0000: adr : 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 000A 000B 000C 000D 000E 000F
-#0000: 0000: 1010 0007 2210 0008 1100 0009 8100 000B 000A 0000 0000 0000 0000 0000 0000 0000
+#0000: 0000: 1010 0007 2210 0008 1100 0009 8100 800B 800A 0000 0000 0000 0000 0000 0000 0000
#0000: 0010: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0000: 0020: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0000: 0030: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0002: Register::::
#0002: GR0: 0 = #0000 = 0000000000000000
-#0002: GR1: 11 = #000B = 0000000000001011
+#0002: GR1: -32757 = #800B = 1000000000001011
#0002: GR2: 0 = #0000 = 0000000000000000
#0002: GR3: 0 = #0000 = 0000000000000000
#0002: GR4: 0 = #0000 = 0000000000000000
#0002: GR7: 0 = #0000 = 0000000000000000
#0002: SP: 512 = #0200 = 0000001000000000
#0002: PR: 2 = #0002 = 0000000000000010
-#0002: FR (OF SF ZF): 000
+#0002: FR (OF SF ZF): 010
#0002: Memory::::
#0002: adr : 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 000A 000B 000C 000D 000E 000F
-#0002: 0000: 1010 0007 2210 0008 1100 0009 8100 000B 000A 0000 0000 0000 0000 0000 0000 0000
+#0002: 0000: 1010 0007 2210 0008 1100 0009 8100 800B 800A 0000 0000 0000 0000 0000 0000 0000
#0002: 0010: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0002: 0020: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0002: 0030: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0004: GR7: 0 = #0000 = 0000000000000000
#0004: SP: 512 = #0200 = 0000001000000000
#0004: PR: 4 = #0004 = 0000000000000100
-#0004: FR (OF SF ZF): 000
+#0004: FR (OF SF ZF): 100
#0004: Memory::::
#0004: adr : 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 000A 000B 000C 000D 000E 000F
-#0004: 0000: 1010 0007 2210 0008 1100 0009 8100 000B 000A 0000 0000 0000 0000 0000 0000 0000
+#0004: 0000: 1010 0007 2210 0008 1100 0009 8100 800B 800A 0000 0000 0000 0000 0000 0000 0000
#0004: 0010: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0004: 0020: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0004: 0030: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0006: GR7: 0 = #0000 = 0000000000000000
#0006: SP: 512 = #0200 = 0000001000000000
#0006: PR: 6 = #0006 = 0000000000000110
-#0006: FR (OF SF ZF): 000
+#0006: FR (OF SF ZF): 100
#0006: Memory::::
#0006: adr : 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 000A 000B 000C 000D 000E 000F
-#0006: 0000: 1010 0007 2210 0008 1100 0009 8100 000B 000A 0000 0000 0000 0000 0000 0000 0000
+#0006: 0000: 1010 0007 2210 0008 1100 0009 8100 800B 800A 0000 0000 0000 0000 0000 0000 0000
#0006: 0010: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0006: 0020: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0006: 0030: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0006 #1030
#0007 #004D
../../../../as/FUNC/hanoi.casl: 7: CALL HANOI
-Assemble error - 103: HANOI: label not found
- ../../../../as/FUNC/hanoi.casl:7: CALL HANOI
-
+ #0008 #8000
+ #0009 #000B
+../../../../as/FUNC/hanoi.casl: 8: RET
+ #000A #8100
+../../../../as/FUNC/hanoi.casl: 9:HANOI CPA GR0,=1
+ #0059 #0001
+ #000B #4000
+ #000C #0059
+../../../../as/FUNC/hanoi.casl: 10: JZE DISP
+ #000D #6300
+ #000E #0032
+../../../../as/FUNC/hanoi.casl: 11: SUBA GR0,=1
+ #005A #0001
+ #000F #2100
+ #0010 #005A
+../../../../as/FUNC/hanoi.casl: 12: PUSH 0,GR2
+ #0011 #7002
+ #0012 #0000
+../../../../as/FUNC/hanoi.casl: 13: PUSH 0,GR3
+ #0013 #7003
+ #0014 #0000
+../../../../as/FUNC/hanoi.casl: 14: POP GR2
+ #0015 #7120
+../../../../as/FUNC/hanoi.casl: 15: POP GR3
+ #0016 #7130
+../../../../as/FUNC/hanoi.casl: 16: CALL HANOI
+ #0017 #8000
+ #0018 #000B
+../../../../as/FUNC/hanoi.casl: 17: PUSH 0,GR2
+ #0019 #7002
+ #001A #0000
+../../../../as/FUNC/hanoi.casl: 18: PUSH 0,GR3
+ #001B #7003
+ #001C #0000
+../../../../as/FUNC/hanoi.casl: 19: POP GR2
+ #001D #7120
+../../../../as/FUNC/hanoi.casl: 20: POP GR3
+ #001E #7130
+../../../../as/FUNC/hanoi.casl: 21: CALL DISP
+ #001F #8000
+ #0020 #0032
+../../../../as/FUNC/hanoi.casl: 22: PUSH 0,GR1
+ #0021 #7001
+ #0022 #0000
+../../../../as/FUNC/hanoi.casl: 23: PUSH 0,GR2
+ #0023 #7002
+ #0024 #0000
+../../../../as/FUNC/hanoi.casl: 24: POP GR1
+ #0025 #7110
+../../../../as/FUNC/hanoi.casl: 25: POP GR2
+ #0026 #7120
+../../../../as/FUNC/hanoi.casl: 26: CALL HANOI
+ #0027 #8000
+ #0028 #000B
+../../../../as/FUNC/hanoi.casl: 27: PUSH 0,GR1
+ #0029 #7001
+ #002A #0000
+../../../../as/FUNC/hanoi.casl: 28: PUSH 0,GR2
+ #002B #7002
+ #002C #0000
+../../../../as/FUNC/hanoi.casl: 29: POP GR1
+ #002D #7110
+../../../../as/FUNC/hanoi.casl: 30: POP GR2
+ #002E #7120
+../../../../as/FUNC/hanoi.casl: 31: ADDA GR0,=1
+ #005B #0001
+ #002F #2000
+ #0030 #005B
+../../../../as/FUNC/hanoi.casl: 32: RET
+ #0031 #8100
+../../../../as/FUNC/hanoi.casl: 33:DISP ST GR1,MSG1
+ #0032 #1110
+ #0033 #0053
+../../../../as/FUNC/hanoi.casl: 34: ST GR3,MSG2
+ #0034 #1130
+ #0035 #0058
+../../../../as/FUNC/hanoi.casl: 35: OUT MSG,LNG
+ #0036 #7001
+ #0037 #0000
+ #0038 #7002
+ #0039 #0000
+ #003A #1210
+ #003B #004E
+ #003C #1020
+ #003D #004A
+ #003E #F000
+ #003F #0002
+ #0040 #1210
+ #0041 #005C
+ #005C #000A
+ #0042 #1220
+ #0043 #0001
+ #0044 #F000
+ #0045 #0002
+ #0046 #7120
+ #0047 #7110
+../../../../as/FUNC/hanoi.casl: 36: RET
+ #0048 #8100
+../../../../as/FUNC/hanoi.casl: 37:N DC 3 ; 輪の総数
+ #0049 #0003
+../../../../as/FUNC/hanoi.casl: 38:LNG DC 11 ; メッセージの長さ
+ #004A #000B
+../../../../as/FUNC/hanoi.casl: 39:A DC 'A'
+ #004B #0041
+../../../../as/FUNC/hanoi.casl: 40:B DC 'B'
+ #004C #0042
+../../../../as/FUNC/hanoi.casl: 41:C DC 'C'
+ #004D #0043
+../../../../as/FUNC/hanoi.casl: 42:MSG DC 'from '
+ #004E #0066
+ #004F #0072
+ #0050 #006F
+ #0051 #006D
+ #0052 #0020
+../../../../as/FUNC/hanoi.casl: 43:MSG1 DS 1
+ #0053 #0000
+../../../../as/FUNC/hanoi.casl: 44: DC ' to '
+ #0054 #0020
+ #0055 #0074
+ #0056 #006F
+ #0057 #0020
+../../../../as/FUNC/hanoi.casl: 45:MSG2 DS 1
+ #0058 #0000
+../../../../as/FUNC/hanoi.casl: 46: END
+from A to C
+from A to B
+from C to B
+from A to C
+from B to A
+from B to C
+from A to C
#0001 #000A
../../../../as/CMD/lad2.casl: 3: LAD GR1,65534,GR1
#0002 #1211
- #0003 #7FFE
+ #0003 #FFFE
../../../../as/CMD/lad2.casl: 4: RET
#0004 #8100
../../../../as/CMD/lad2.casl: 5: END
#0000: FR (OF SF ZF): 000
#0000: Memory::::
#0000: adr : 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 000A 000B 000C 000D 000E 000F
-#0000: 0000: 1210 000A 1211 7FFE 8100 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
+#0000: 0000: 1210 000A 1211 FFFE 8100 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0000: 0010: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0000: 0020: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0000: 0030: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0002: FR (OF SF ZF): 000
#0002: Memory::::
#0002: adr : 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 000A 000B 000C 000D 000E 000F
-#0002: 0000: 1210 000A 1211 7FFE 8100 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
+#0002: 0000: 1210 000A 1211 FFFE 8100 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0002: 0010: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0002: 0020: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0002: 0030: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0004: Register::::
#0004: GR0: 0 = #0000 = 0000000000000000
-#0004: GR1: -32760 = #8008 = 1000000000001000
+#0004: GR1: 8 = #0008 = 0000000000001000
#0004: GR2: 0 = #0000 = 0000000000000000
#0004: GR3: 0 = #0000 = 0000000000000000
#0004: GR4: 0 = #0000 = 0000000000000000
#0004: FR (OF SF ZF): 000
#0004: Memory::::
#0004: adr : 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 000A 000B 000C 000D 000E 000F
-#0004: 0000: 1210 000A 1211 7FFE 8100 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
+#0004: 0000: 1210 000A 1211 FFFE 8100 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0004: 0010: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0004: 0020: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0004: 0030: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0001 #FFFF
../../../../as/CMD/lad3.casl: 3: LAD GR1,65535,GR1
#0002 #1211
- #0003 #7FFF
+ #0003 #FFFF
../../../../as/CMD/lad3.casl: 4: RET
#0004 #8100
../../../../as/CMD/lad3.casl: 5: END
#0000: FR (OF SF ZF): 000
#0000: Memory::::
#0000: adr : 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 000A 000B 000C 000D 000E 000F
-#0000: 0000: 1210 FFFF 1211 7FFF 8100 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
+#0000: 0000: 1210 FFFF 1211 FFFF 8100 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0000: 0010: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0000: 0020: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0000: 0030: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0002: FR (OF SF ZF): 000
#0002: Memory::::
#0002: adr : 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 000A 000B 000C 000D 000E 000F
-#0002: 0000: 1210 FFFF 1211 7FFF 8100 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
+#0002: 0000: 1210 FFFF 1211 FFFF 8100 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0002: 0010: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0002: 0020: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0002: 0030: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0004: Register::::
#0004: GR0: 0 = #0000 = 0000000000000000
-#0004: GR1: 32766 = #7FFE = 0111111111111110
+#0004: GR1: -2 = #FFFE = 1111111111111110
#0004: GR2: 0 = #0000 = 0000000000000000
#0004: GR3: 0 = #0000 = 0000000000000000
#0004: GR4: 0 = #0000 = 0000000000000000
#0004: FR (OF SF ZF): 000
#0004: Memory::::
#0004: adr : 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 000A 000B 000C 000D 000E 000F
-#0004: 0000: 1210 FFFF 1211 7FFF 8100 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
+#0004: 0000: 1210 FFFF 1211 FFFF 8100 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0004: 0010: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0004: 0020: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
#0004: 0030: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
+++ /dev/null
-../../../../casl2: invalid option -- z
-Usage: ../../../../casl2 [-slLaAtTdh] [-oO<OUTFILE>] [-M <memorysize>] [-C <clocks>] FILE ...
--- /dev/null
+0
+1
+10
+32767
+32768
+65535
+65536
+65537
+\-\-\ \-1
+\-\-\ \-10
+\-\-\ \-32767
+\-\-\ \-32768
+\-\-\ \-32769
+\'#0\'
+\'#1\'
+\'#01\'
+\'#001\'
+\'#0001\'
+\'#10\'
+\'#11\'
+\'#F\'
+\'#000F\'
+\'#FFFF\'
+\'#00001\'
+\'#G\'
+++ /dev/null
-0
-1
-01
-001
-0001
-10
-11
-F
-000F
-FFFF
-00001
-G
0.txt 1.txt: $(DUMPWORD) $(TESTSH)
@sh $(TESTSH) >>$@ 2>$(ERRFILE); \
if test -s $(ERRFILE); then cat err.txt >>$@; else rm -f $(ERRFILE); fi
-$(TESTSH): ../HEX.txt
+$(TESTSH): ../ARGS.txt
@xargs -n1 echo "$(DUMPWORD) $(DUMPWORDFLAG) " <$^ >$@
diff.txt: 1.txt
@-diff -c 0.txt 1.txt >$@ 2>&1
- 0: 0 = #0000 = 0000000000000000
- 1: 1 = #0001 = 0000000000000001
- 01: 1 = #0001 = 0000000000000001
- 001: 1 = #0001 = 0000000000000001
-0001: 1 = #0001 = 0000000000000001
- 10: 16 = #0010 = 0000000000010000
- 11: 17 = #0011 = 0000000000010001
- F: 15 = #000F = 0000000000001111
-000F: 15 = #000F = 0000000000001111
-FFFF: -1 = #FFFF = 1111111111111111
-Dumpword Error - 116: 00001: out of hex range
-Dumpword Error - 115: G: not hex
+ 0: 0 = #0000 = 0000000000000000
+ 1: 1 = #0001 = 0000000000000001
+ 10: 10 = #000A = 0000000000001010
+ 32767: 32767 = #7FFF = 0111111111111111
+ 32768: -32768 = #8000 = 1000000000000000
+ 65535: -1 = #FFFF = 1111111111111111
+ 65536: 0 = #0000 = 0000000000000000
+ 65537: 1 = #0001 = 0000000000000001
+ -1: -1 = #FFFF = 1111111111111111
+ -10: -10 = #FFF6 = 1111111111110110
+-32767: -32767 = #8001 = 1000000000000001
+-32768: -32768 = #8000 = 1000000000000000
+-32769: 32767 = #7FFF = 0111111111111111
+ #0: 0 = #0000 = 0000000000000000
+ #1: 1 = #0001 = 0000000000000001
+ #01: 1 = #0001 = 0000000000000001
+ #001: 1 = #0001 = 0000000000000001
+ #0001: 1 = #0001 = 0000000000000001
+ #10: 16 = #0010 = 0000000000010000
+ #11: 17 = #0011 = 0000000000010001
+ #F: 15 = #000F = 0000000000001111
+ #000F: 15 = #000F = 0000000000001111
+ #FFFF: -1 = #FFFF = 1111111111111111
+Dumpword Error - 116: #00001: out of hex range
+Dumpword Error - 115: #G: not hex
+++ /dev/null
-Dumpword Error - 116: 00001: out of hex range
-Dumpword Error - 115: G: not hex
- 0: 0 = #0000 = 0000000000000000
- 1: 1 = #0001 = 0000000000000001
- 01: 1 = #0001 = 0000000000000001
- 001: 1 = #0001 = 0000000000000001
-0001: 1 = #0001 = 0000000000000001
- 10: 16 = #0010 = 0000000000010000
- 11: 17 = #0011 = 0000000000010001
- F: 15 = #000F = 0000000000001111
-000F: 15 = #000F = 0000000000001111
-FFFF: 65535 = #FFFF = 1111111111111111
-Dumpword Error - 116: 00001: out of hex range
-Dumpword Error - 115: G: not hex
+ 0: 0 = #0000 = 0000000000000000
+ 1: 1 = #0001 = 0000000000000001
+ 10: 10 = #000A = 0000000000001010
+ 32767: 32767 = #7FFF = 0111111111111111
+ 32768: 32768 = #8000 = 1000000000000000
+ 65535: 65535 = #FFFF = 1111111111111111
+ 65536: 0 = #0000 = 0000000000000000
+ 65537: 1 = #0001 = 0000000000000001
+ -1: 65535 = #FFFF = 1111111111111111
+ -10: 65526 = #FFF6 = 1111111111110110
+-32767: 32769 = #8001 = 1000000000000001
+-32768: 32768 = #8000 = 1000000000000000
+-32769: 32767 = #7FFF = 0111111111111111
+ #0: 0 = #0000 = 0000000000000000
+ #1: 1 = #0001 = 0000000000000001
+ #01: 1 = #0001 = 0000000000000001
+ #001: 1 = #0001 = 0000000000000001
+ #0001: 1 = #0001 = 0000000000000001
+ #10: 16 = #0010 = 0000000000010000
+ #11: 17 = #0011 = 0000000000010001
+ #F: 15 = #000F = 0000000000001111
+ #000F: 15 = #000F = 0000000000001111
+ #FFFF: 65535 = #FFFF = 1111111111111111
+Dumpword Error - 116: #00001: out of hex range
+Dumpword Error - 115: #G: not hex
+++ /dev/null
-Dumpword Error - 116: 00001: out of hex range
-Dumpword Error - 115: G: not hex
- 0: 0 = #0000 = 0000000000000000
- 1: 1 = #0001 = 0000000000000001
- 01: 1 = #0001 = 0000000000000001
- 001: 1 = #0001 = 0000000000000001
-0001: 1 = #0001 = 0000000000000001
- 10: 16 = #0010 = 0000000000010000
- 11: 17 = #0011 = 0000000000010001
- F: 15 = #000F = 0000000000001111
-000F: 15 = #000F = 0000000000001111
-FFFF: -1 = #FFFF = 1111111111111111
-Dumpword Error - 116: 00001: out of hex range
-Dumpword Error - 115: G: not hex
+ 0: 0 = #0000 = 0000000000000000
+ 1: 1 = #0001 = 0000000000000001
+ 10: 10 = #000A = 0000000000001010
+ 32767: 32767 = #7FFF = 0111111111111111
+ 32768: -32768 = #8000 = 1000000000000000
+ 65535: -1 = #FFFF = 1111111111111111
+ 65536: 0 = #0000 = 0000000000000000
+ 65537: 1 = #0001 = 0000000000000001
+ -1: -1 = #FFFF = 1111111111111111
+ -10: -10 = #FFF6 = 1111111111110110
+-32767: -32767 = #8001 = 1000000000000001
+-32768: -32768 = #8000 = 1000000000000000
+-32769: 32767 = #7FFF = 0111111111111111
+ #0: 0 = #0000 = 0000000000000000
+ #1: 1 = #0001 = 0000000000000001
+ #01: 1 = #0001 = 0000000000000001
+ #001: 1 = #0001 = 0000000000000001
+ #0001: 1 = #0001 = 0000000000000001
+ #10: 16 = #0010 = 0000000000010000
+ #11: 17 = #0011 = 0000000000010001
+ #F: 15 = #000F = 0000000000001111
+ #000F: 15 = #000F = 0000000000001111
+ #FFFF: -1 = #FFFF = 1111111111111111
+Dumpword Error - 116: #00001: out of hex range
+Dumpword Error - 115: #G: not hex
+++ /dev/null
-Dumpword Error - 116: 00001: out of hex range
-Dumpword Error - 115: G: not hex