check:
@rm -f $(LOGFILE)
@for target in $(TESTS); do \
- $(MAKE) check -C $$target; \
+ $(MAKE) check -sC $$target; \
done
$(LOGFILE):
@for target in $(TESTS); do \
ASSRC = $(SRCDIR)/assemble.o $(SRCDIR)/token.o $(SRCDIR)/label.o $(SRCDIR)/macro.o
EXECSRC = $(SRCDIR)/exec.o $(SRCDIR)/dump.o
+ifeq "$(UCLASS)" "ALL"
+ SRC = $(COMMONSRC) $(ASSRC) $(EXECSRC)
+endif
ifeq "$(UCLASS)" "AS"
SRC = $(COMMONSRC) $(ASSRC)
endif
--- /dev/null
+126: source file is not specified
+101: label already defined
+102: label table is full
+103: label not found
+104: label length is too long
+105: no command in the line
+106: operand mismatch in assemble command
+107: no label in START
+108: not command of operand "r"
+109: not command of operand "r1,r2"
+110: not command of operand "r,adr[,x]"
+111: not command of operand "adr[,x]"
+112: not command of no operand
+113: operand too many in COMET II command
+117: operand too many in DC
+118: operand length too long
+119: out of COMET II memory
+120: GR0 in operand x
+121: cannot get operand token
+122: cannot create hash table
+123: unclosed quote
+124: more than one character in literal
+125: not GR in operand x
+114: not integer
+115: not hex
+116: out of hex range
+114: not integer
+115: not hex
+116: out of hex range
+201: Load object file - full of COMET II memory
+202: SVC input - out of Input memory
+203: SVC output - out of COMET II memory
+204: Program Register (PR) - out of COMET II memory
+205: Stack Pointer (SP) - cannot allocate stack buffer
+206: Address - out of COMET II memory
+207: Stack Pointer (SP) - out of COMET II memory
205: (null) - 205 Stack Pointer (SP) - cannot allocate stack buffer
206: (null) - 206 Address - out of COMET II memory
207: (null) - 207 Stack Pointer (SP) - out of COMET II memory
-999: (null) - 999 unkown error
+999: (null) - 999 unknown error
101: foobar - 101 foobar: label already defined
102: foobar - 102 foobar: label table is full
103: foobar - 103 foobar: label not found
205: foobar - 205 foobar: Stack Pointer (SP) - cannot allocate stack buffer
206: foobar - 206 foobar: Address - out of COMET II memory
207: foobar - 207 foobar: Stack Pointer (SP) - out of COMET II memory
-999: foobar - 999 foobar: unkown error
+999: foobar - 999 foobar: unknown error
{ "SVC", ADR_X }, { "RET", NONE }
};
create_cmdtype_code();
- /* エラーの初期化 */
- cerr = malloc_chk(sizeof(CERR), "cerr");
+ cerr = malloc_chk(sizeof(CERR), "cerr"); /* エラーの初期化 */
for(i = 0; i < sizeof(cmdcodelist)/sizeof(cmdcodelist[0]); i++) {
code = getcmdcode(cmdcodelist[i].cmd, cmdcodelist[i].type);
printf("%s:0%02o ---> #%04X\n", cmdcodelist[i].cmd, cmdcodelist[i].type, code);
0x6400, 0x6500, 0x6600, 0x7000, 0x7100,
0x8000, 0xF000, 0x8100
};
+
+ cerr = malloc_chk(sizeof(CERR), "cerr"); /* エラーの初期化 */
create_code_type();
for(i = 0; i < ARRAYSIZE(codelist); i++) {
type = getcmdtype(codelist[i]);
printf("#%04X ---> 0%02o\n", codelist[i], type);
- if(cerrno != 0) {
- printf("\t%s", cerrmsg);
+ if(cerr->num != 0) {
+ printf("\t%s", cerr->msg);
freecerr();
}
}
"", "0", "aaa", "GR", "GR8", "GR20",
"GR0", "GR1", "GR2", "GR3", "GR4", "GR5", "GR6", "GR7"
};
+
+ cerr = malloc_chk(sizeof(CERR), "cerr"); /* エラーの初期化 */
+ addcerrlist_assemble();
for(i = 0; i <= 1; i++) {
title = (is_x[i] == false) ? "Generel Register" : "Index Register";
printf("== %s ==\n", title);
for(j = 0; j < ARRAYSIZE(str); j++) {
+ cerr->num = 0;
r = getgr(str[j], is_x[i]);
printf("%s\t#%04X", str[j], r);
- if(cerrno > 0) {
- printf("\tError - %d\t%s", cerrno, cerrmsg);
- freecerr();
+ if(cerr->num > 0) {
+ printf("\tError - %d\t%s", cerr->num, cerr->msg);
}
printf("\n");
}
}
+ freecerr();
return 0;
}
char *str[] = {
"#32768", "#-1", "#G", "#FFFF", "#0", "#1", "#ab", "#AB", "#20"
};
+
+ cerr = malloc_chk(sizeof(CERR), "cerr"); /* エラーの初期化 */
+ addcerrlist_word();
for(i = 0; i < sizeof(str)/sizeof(str[0]); i++) {
+ cerr->num = 0;
r = h2word(str[i]);
printf("%s\t#%04X", str[i], r);
- if(cerrno > 0) {
- printf("\tError - %d\t%s", cerrno, cerrmsg);
- freecerr();
+ if(cerr->num > 0) {
+ printf("\tError - %d\t%s", cerr->num, cerr->msg);
}
printf("\n");
}
+ freecerr();
return 0;
}
HASH VALUE: 20
HASH VALUE: 11
-HASH VALUE: 2
+HASH VALUE: 16
unsigned hash_char2_int2(int tsize)
{
char *str[2] = {"abc", "123"};
- int num[2] = {19, 11}, i;
+ int num[2] = {19, 11}, i, cnt = 0;
HKEY *keys[4];
/* ハッシュ共用体の設定 */
for(i = 0; i < 2; i++) {
- keys[i] = malloc(sizeof(HKEY));
- keys[i]->type = CHARS;
- keys[i]->val.s = strdup(str[i]);
+ keys[cnt] = malloc(sizeof(HKEY));
+ keys[cnt]->type = CHARS;
+ keys[cnt++]->val.s = strdup(str[i]);
}
- for(i = 2; i < 4; i++) {
- keys[i] = malloc(sizeof(HKEY));
- keys[i]->type = INT;
- keys[i]->val.i = num[i];
+ for(i = 0; i < 2; i++) {
+ keys[cnt] = malloc(sizeof(HKEY));
+ keys[cnt]->type = INT;
+ keys[cnt++]->val.i = num[i];
}
/* ハッシュ値を取得する */
return hash(4, keys, tsize);
8:
cl is NULL
+ error - 121: cannot get operand token
9: ;comment
cl is NULL
+ error - 121: cannot get operand token
"\n",
" ;comment\n"
};
+
CMDLINE *testcl = malloc(sizeof(CMDLINE));
-
+ cerr = malloc_chk(sizeof(CERR), "cerr"); /* エラーの初期化 */
+ addcerrlist_assemble();
for(i = 0; i < sizeof testline /sizeof testline[0]; i++) {
printf("%d: %s", i, testline[i]);
testcl = linetok(testline[i]);
}
}
}
- if(cerrno != 0) {
- printf("\terror - %d: %s\n", cerrno, cerrmsg);
- freecerr();
+ if(cerr->num != 0) {
+ printf("\terror - %d: %s\n", cerr->num, cerr->msg);
}
printf("\n");
}
+ freecerr();
return 0;
}
"0", "01", "1a", "-5G", "123", "32767", "32768", "32769",
"-1", "-2345", "-32768", "-32769", "-32770"
};
+
+ cerr = malloc_chk(sizeof(CERR), "cerr"); /* エラーの初期化 */
+ addcerrlist_word();
for(i = 0; i < sizeof(str)/sizeof(str[0]); i++) {
+ cerr->num = 0;
r = n2word(str[i]);
printf("%s\t0x%04x", str[i], r);
- if(cerrno > 0) {
- printf("\tError - %d\t%s", cerrno, cerrmsg);
- freecerr();
+ if(cerr->num > 0) {
+ printf("\tError - %d\t%s", cerr->num, cerr->msg);
}
printf("\n");
}
+ freecerr();
return 0;
}
OPDC[37]:8
OPDC[38]:9
OPDC[39]:0
-Error - 117: operand is too many
+Error - 117: operand too many in DC
'1234567890123456789012345678901234567890'
OPDC:1
'12345678901234567890123456789012345678901'
OPDC:0
-Error - 118: operand length is too long
+Error - 118: operand length too long
"\'1234567890123456789012345678901234567890\'",
"\'12345678901234567890123456789012345678901\'",
};
+
+ cerr = malloc_chk(sizeof(CERR), "cerr"); /* エラーの初期化 */
+ addcerrlist_assemble();
for(i = 0; i < ARRAYSIZE(str); i++) {
+ cerr->num = 0;
printf("%s\n", str[i]);
opd = opdtok(str[i]);
printf("OPDC:%d\n", opd->opdc);
for(j = 0; j < opd->opdc; j++) {
printf("OPDC[%d]:%s\n", j, opd->opdv[j]);
}
- if(cerrno > 0){
- printf("Error - %d: %s\n", cerrno, cerrmsg);
- freecerr();
+ if(cerr->num > 0){
+ printf("Error - %d: %s\n", cerr->num, cerr->msg);
}
printf("\n");
}
+ freecerr();
return 0;
}
-UCLASS = COMMON
+UCLASS = ALL
TESTSRCFILE = ../CERRARRAY.c print_cerrmsg.c
include ../TEST.mk
#include <stdio.h>
#include "casl2.h"
+#include "assemble.h"
+#include "exec.h"
int main(){
- int i, num;
+ CERRLIST *p;
- for(i = 0; (num = cerr[i].num) > 0; i++) {
- setcerr(num, NULL);
- printf("%d: %s\n", cerrno, cerrmsg);
- freecerr();
+ addcerrlist_word();
+ addcerrlist_assemble();
+ addcerrlist_exec();
+ cerr = malloc_chk(sizeof(CERR), "cerr"); /* エラーの初期化 */
+ for(p = cerrlist; p != NULL; p = p->next) {
+ setcerr(p->cerr->num, NULL);
+ printf("%d: %s\n", cerr->num, cerr->msg);
}
+ freecerr();
return 0;
}
int compare_code(const void *a, const void *b)
{
- const CMDTYPECODE ca = **(const CMDTYPECODE **)a;
- const CMDTYPECODE cb = **(const CMDTYPECODE **)b;
+ const CMD ca = **(const CMD **)a;
+ const CMD cb = **(const CMD **)b;
int diff;
- if((diff = strcmp(ca.cmd, cb.cmd)) == 0) {
+
+ if((diff = strcmp(ca.name, cb.name)) == 0) {
return ca.type - cb.type;
} else {
return diff;
void print_cmdtype_code()
{
int i, j = 0;
- CMDCODETAB *np;
- CMDTYPECODE **ar;
- ar = malloc(sizeof(*ar) * cmdtypecodesize);
- for(i = 0; i < cmdtabsize; i++) {
+ CMDTAB *np;
+ CMD **ar;
+ ar = malloc(sizeof(*ar) * comet2cmdsize);
+ for(i = 0; i < comet2cmdsize; i++) {
np = cmdtype_code[i];
while(np != NULL) {
- ar[j++] = np->cmdtypecode;
+ ar[j++] = np->cmd;
np = np->next;
}
}
- qsort(ar, cmdcodesize, sizeof(*ar), (int (*)(const void*, const void*))compare_code);
- for(i = 0; i < cmdcodesize; i++) {
- fprintf(stdout, "%s\t0%02o\t#%04X\n", ar[i]->cmd, ar[i]->type, ar[i]->code);
+ qsort(ar, comet2cmdsize, sizeof(*ar), (int (*)(const void*, const void*))compare_code);
+ for(i = 0; i < comet2cmdsize; i++) {
+ fprintf(stdout, "%s\t0%02o\t#%04X\n", ar[i]->name, ar[i]->type, ar[i]->code);
}
}
void print_cmdtype_code()
{
int i;
- CMDCODETAB *np;
- for(i = 0; i < cmdtabsize; i++){
+ CMDTAB *np;
+ for(i = 0; i < comet2cmdsize; i++){
np = cmdtype_code[i];
while(np != NULL) {
fprintf(stdout, "(%2d) - %s\t0%02o\t#%04X\n",
- i, np->cmdtypecode->cmd, np->cmdtypecode->type, np->cmdtypecode->code);
+ i, np->cmd->name, np->cmd->type, np->cmd->code);
np = np->next;
}
}
int compare_code(const void *a, const void *b)
{
- return (**(const CMDTYPECODE **)a).code - (**(const CMDTYPECODE **)b).code;
+ return (**(const CMD **)a).code - (**(const CMD **)b).code;
}
/* 命令コードがキーのハッシュ表を表示する */
void print_code_type()
{
int i, j = 0;
- CMDCODETAB *np;
- CMDTYPECODE **ar;
- ar = malloc(sizeof(*ar) * cmdtypecodesize);
+ CMDTAB *np;
+ CMD **ar;
+ ar = malloc(sizeof(*ar) * comet2cmdsize);
for(i = 0; i < cmdtabsize; i++) {
np = code_type[i];
while(np != NULL) {
- ar[j++] = np->cmdtypecode;
+ ar[j++] = np->cmd;
np = np->next;
}
}
- qsort(ar, cmdtypecodesize, sizeof(*ar), (int (*)(const void*, const void*))compare_code);
- for(i = 0; i < cmdtypecodesize; i++) {
- fprintf(stdout, "#%04X\t0%02o\t%s\n", ar[i]->code, ar[i]->type, ar[i]->cmd);
+ qsort(ar, comet2cmdsize, sizeof(*ar), (int (*)(const void*, const void*))compare_code);
+ for(i = 0; i < comet2cmdsize; i++) {
+ fprintf(stdout, "#%04X\t0%02o\t%s\n", ar[i]->code, ar[i]->type, ar[i]->name);
}
}
void print_code_type()
{
int i;
- CMDCODETAB *np;
+ CMDTAB *np;
for(i = 0; i < cmdtabsize; i++){
for(np = code_type[i]; np != NULL; np = np->next) {
fprintf(stdout, "(%2d) - #%04X\t0%02o\t%s\n",
- i, np->cmdtypecode->code, np->cmdtypecode->type, np->cmdtypecode->cmd);
+ i, np->cmd->code, np->cmd->type, np->cmd->name);
}
}
}