From 201417091a96aa8437f7773b8cedf2875805c670 Mon Sep 17 00:00:00 2001 From: j8takagi Date: Tue, 19 Jun 2018 17:36:24 +0900 Subject: [PATCH] =?utf8?q?CASL2LIB=E3=81=AE=E4=BD=9C=E6=88=90=E3=80=81?= =?utf8?q?=E4=BF=AE=E6=AD=A3=E3=80=81=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- as/casl2lib/sample/call_str2l.casl | 44 ++++++++++++++++++++++++ as/casl2lib/src/mull0.casl | 25 ++++++++++++++ test/system/casl2_lib/lib_str2l/0.txt | 4 +++ test/system/casl2_lib/lib_str2l/Makefile | 2 ++ test/system/casl2_lib/lib_str2l/cmd | 1 + 5 files changed, 76 insertions(+) create mode 100644 as/casl2lib/sample/call_str2l.casl create mode 100644 as/casl2lib/src/mull0.casl create mode 100644 test/system/casl2_lib/lib_str2l/0.txt create mode 100644 test/system/casl2_lib/lib_str2l/Makefile create mode 100755 test/system/casl2_lib/lib_str2l/cmd diff --git a/as/casl2lib/sample/call_str2l.casl b/as/casl2lib/sample/call_str2l.casl new file mode 100644 index 0000000..211ba9c --- /dev/null +++ b/as/casl2lib/sample/call_str2l.casl @@ -0,0 +1,44 @@ +;;; casl2 call_str2l.casl stdlib.casl +MAIN START + XOR GR4,GR4 + LAD GR6,LEN +BLP LAD GR1,STR,GR4 + LD GR2,0,GR6 + JZE FIN + LD GR5,GR1 + CALL STR2L + JOV OV + JMI NAN + LD GR1,GR3 + CALL OUTL + LD GR1,GR5 + JUMP ELP +OV OUT MSGOV,LENOV + JUMP ELP +NAN OUT MSGNAN,LENNAN +ELP ADDL GR4,GR2 + LAD GR6,1,GR6 + JUMP BLP +FIN RET +STR DC '0' + DC '1' + DC '123' + DC '1234' + DC '65535' + DC '65536' + DC '123456' + DC 'a' +LEN DC 1 + DC 1 + DC 3 + DC 4 + DC 5 + DC 5 + DC 6 + DC 1 + DC 0 +MSGOV DC 'over 65535' +LENOV DC 10 +MSGNAN DC 'not a logical integer' +LENNAN DC 21 + END diff --git a/as/casl2lib/src/mull0.casl b/as/casl2lib/src/mull0.casl new file mode 100644 index 0000000..83cac02 --- /dev/null +++ b/as/casl2lib/src/mull0.casl @@ -0,0 +1,25 @@ +; 符号なし乗算 +; 入力 +; GR0 = 被乗数 +; GR1 = 乗数 +; 出力 +; GR3 = 結果 +MULL START +; レジスタを退避 + PUSH 0,GR1 + PUSH 0,GR2 +; 初期化 + XOR GR3,GR3 ; GR3 = 積 +; 被乗数をシフトしながら加算していく +LOOP SRL GR2,1 ; 最下位ビットが + JOV ONE ; 1なら加算 + JUMP ZERO ; 0なら加算しない +ONE ADDL GR3,GR1 ; +ZERO SLL GR1,1 ; 被乗数をシフト + AND GR2,GR2 ; 乗数に1のビットが + JNZ LOOP ; あれば続行 +; レジスタを復元 + POP GR2 + POP GR1 + RET + END diff --git a/test/system/casl2_lib/lib_str2l/0.txt b/test/system/casl2_lib/lib_str2l/0.txt new file mode 100644 index 0000000..b5daef5 --- /dev/null +++ b/test/system/casl2_lib/lib_str2l/0.txt @@ -0,0 +1,4 @@ +345 +not a logical integer +not a logical integer +over 65535 diff --git a/test/system/casl2_lib/lib_str2l/Makefile b/test/system/casl2_lib/lib_str2l/Makefile new file mode 100644 index 0000000..b6dac59 --- /dev/null +++ b/test/system/casl2_lib/lib_str2l/Makefile @@ -0,0 +1,2 @@ +include ../Define.mk +include ../Test.mk diff --git a/test/system/casl2_lib/lib_str2l/cmd b/test/system/casl2_lib/lib_str2l/cmd new file mode 100755 index 0000000..aeab1eb --- /dev/null +++ b/test/system/casl2_lib/lib_str2l/cmd @@ -0,0 +1 @@ +../../../../casl2 -M1024 ../../../../as/casl2lib/sample/call_str2l.casl ../../../../as/casl2lib/str2l.casl ../../../../as/casl2lib/outl.casl -- 2.18.0