CASL2LIBの作成、修正、整理
authorj8takagi <j8takagi@nifty.com>
Tue, 19 Jun 2018 08:36:24 +0000 (17:36 +0900)
committerj8takagi <j8takagi@nifty.com>
Tue, 19 Jun 2018 08:36:24 +0000 (17:36 +0900)
as/casl2lib/sample/call_str2l.casl [new file with mode: 0644]
as/casl2lib/src/mull0.casl [new file with mode: 0644]
test/system/casl2_lib/lib_str2l/0.txt [new file with mode: 0644]
test/system/casl2_lib/lib_str2l/Makefile [new file with mode: 0644]
test/system/casl2_lib/lib_str2l/cmd [new file with mode: 0755]

diff --git a/as/casl2lib/sample/call_str2l.casl b/as/casl2lib/sample/call_str2l.casl
new file mode 100644 (file)
index 0000000..211ba9c
--- /dev/null
@@ -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 (file)
index 0000000..83cac02
--- /dev/null
@@ -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 (file)
index 0000000..b5daef5
--- /dev/null
@@ -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 (file)
index 0000000..b6dac59
--- /dev/null
@@ -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 (executable)
index 0000000..aeab1eb
--- /dev/null
@@ -0,0 +1 @@
+../../../../casl2 -M1024 ../../../../as/casl2lib/sample/call_str2l.casl ../../../../as/casl2lib/str2l.casl ../../../../as/casl2lib/outl.casl