From: j8takagi Date: Sat, 6 Feb 2010 04:36:33 +0000 (+0900) Subject: SVC 2とOUTの仕様を修正 X-Git-Tag: v0.1~63 X-Git-Url: https://j8takagi.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=87da65b534d88b60dcfb59ff1252101daf35e44e;p=YACASL2.git SVC 2とOUTの仕様を修正 SVC 2で、文字の長さを「GR2の内容」から「GR2のアドレスに格納された内容」で取得 それに伴い、マクロ命令OUTの生成する命令群も変更 --- diff --git a/src/cerr.c b/src/cerr.c index 121b680..be3e58b 100644 --- a/src/cerr.c +++ b/src/cerr.c @@ -7,7 +7,7 @@ char *cerrmsg; /* エラー番号とエラーメッセージを設定する */ void setcerr(int num, const char *val) { - assert(&cerr != NULL && num > 0); + assert(cerr != NULL && num > 0); cerrno = num; cerrmsg = malloc(MSGSIZE + 1); @@ -23,7 +23,7 @@ void setcerr(int num, const char *val) /* エラー番号からメッセージを返す */ char *getcerrmsg(int num) { - assert(&cerr != NULL && num > 0); + assert(cerr != NULL && num > 0); int i = 0; CERRARRAY *ptr; diff --git a/src/cmd.c b/src/cmd.c index 93ae8cd..83e80af 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -38,7 +38,7 @@ CMDCODEARRAY cmdcodearray[] = { { "POP", R_, 0x7100 }, { "CALL", ADR_X, 0x8000 }, { "SVC", ADR_X, 0xF000 }, - { "RET", NONE, 0x8100 } + { "RET", NONE, 0x8100 }, }; int cmdcodesize = ARRAYSIZE(cmdcodearray); diff --git a/src/exec.c b/src/exec.c index 748c72b..29b1afc 100644 --- a/src/exec.c +++ b/src/exec.c @@ -32,7 +32,7 @@ void svcout() int i; WORD w; - for(i = 0; i < GR[2]; i++) { + for(i = 0; i < memory[GR[2]]; i++) { if(GR[1] + i >= memsize - 1) { setcerr(203, NULL); /* SVC output - out of Comet II memory */ return; diff --git a/src/macro.c b/src/macro.c index 019b956..354e7ec 100644 --- a/src/macro.c +++ b/src/macro.c @@ -1,15 +1,14 @@ #include "casl2.h" #include "assemble.h" -/*マクロ命令「IN IBUF,LEN」をメモリに書込 - PUSH 0,GR1 - PUSH 0,GR2 - LAD GR1,IBUF - LAD GR2,LEN - SVC 1 - POP GR2 - POP GR1 -*/ +/* マクロ命令「IN IBUF,LEN」をメモリに書込 */ +/* PUSH 0,GR1 */ +/* PUSH 0,GR2 */ +/* LAD GR1,IBUF */ +/* LAD GR2,LEN */ +/* SVC 1 */ +/* POP GR2 */ +/* POP GR1 */ bool writeIN(const char *ibuf, const char *len, PASS pass) { bool status = false; @@ -39,18 +38,17 @@ bool writeIN(const char *ibuf, const char *len, PASS pass) return status; } -/* マクロ命令「OUT OBUF,LEN」をメモリに書込 - PUSH 0,GR1 - PUSH 0,GR2 - LAD GR1,OBUF - LD GR2,LEN - SVC 2 - LAD GR1,=#A - LAD GR2,1 - SVC 2 - POP GR2 - POP GR1 -*/ +/* マクロ命令「OUT OBUF,LEN」をメモリに書込 */ +/* PUSH 0,GR1 */ +/* PUSH 0,GR2 */ +/* LAD GR1,OBUF */ +/* LAD GR2,LEN */ +/* SVC 2 */ +/* LAD GR1,=#A */ +/* LAD GR2,1 */ +/* SVC 2 */ +/* POP GR2 */ +/* POP GR1 */ bool writeOUT(const char *obuf, const char *len, PASS pass) { bool status = false; @@ -64,13 +62,13 @@ bool writeOUT(const char *obuf, const char *len, PASS pass) /* LAD GR1,OBUF */ writememory(0x1210, ptr++, pass); writememory(getadr(prog, obuf, pass), ptr++, pass); - /* LD GR2,OLEN */ - writememory(0x1020, ptr++, pass); + /* LAD GR2,OLEN */ + writememory(0x1220, ptr++, pass); writememory(getadr(prog, len, pass), ptr++, pass); /* SVC 2 */ writememory(0xF000, ptr++, pass); writememory(0x0002, ptr++, pass); - /* LAD GR1,=#A */ + /* LAD GR1,=#A */ writememory(0x1210, ptr++, pass); if(pass == FIRST) { ptr++; @@ -78,9 +76,14 @@ bool writeOUT(const char *obuf, const char *len, PASS pass) writememory(lptr, ptr++, pass); /* リテラルのアドレスを書込 */ } writememory(0xA, lptr++, pass); - /* LAD GR2,1 */ + /* LAD GR2,=1 */ writememory(0x1220, ptr++, pass); - writememory(0x0001, ptr++, pass); + if(pass == FIRST) { + ptr++; + } else { + writememory(lptr, ptr++, pass); /* リテラルのアドレスを書込 */ + } + writememory(0x1, lptr++, pass); /* SVC 2 */ writememory(0xF000, ptr++, pass); writememory(0x0002, ptr++, pass); @@ -95,13 +98,13 @@ bool writeOUT(const char *obuf, const char *len, PASS pass) } /* マクロ命令「RPUSH」をメモリに書き込む - PUSH 0,GR1 + PUSH 0,GR1 PUSH 0,GR2 - PUSH 0,GR3 + PUSH 0,GR3 PUSH 0,GR4 - PUSH 0,GR5 + PUSH 0,GR5 PUSH 0,GR6 - PUSH 0,GR7 + PUSH 0,GR7 */ bool writeRPUSH(PASS pass) { int i; @@ -118,14 +121,14 @@ bool writeRPUSH(PASS pass) { } /* マクロ命令「RPOP」をメモリに書き込む - POP GR7 - POP GR6 - POP GR5 - POP GR4 - POP GR3 - POP GR3 - POP GR2 - POP GR1 + POP GR7 + POP GR6 + POP GR5 + POP GR4 + POP GR3 + POP GR3 + POP GR2 + POP GR1 */ bool writeRPOP(PASS pass) { int i;