CASLファイルの構成変更。casllibとmiscを分離
authorj8takagi <j8takagi@nifty.com>
Sun, 7 Feb 2010 09:03:16 +0000 (18:03 +0900)
committerj8takagi <j8takagi@nifty.com>
Sun, 7 Feb 2010 09:03:16 +0000 (18:03 +0900)
44 files changed:
as/casl2lib/count1.casl [deleted file]
as/casl2lib/minim.casl
as/casl2lib/mula.casl [moved from as/casl2lib/mula2.casl with 100% similarity]
as/casl2lib/mula1.casl [deleted file]
as/casl2lib/mull.casl [moved from as/casl2lib/mull1.casl with 100% similarity]
as/casl2lib/outa0.casl [deleted file]
as/casl2lib/sum.casl
as/casl2lib_test/abs_call.casl [moved from as/casl2lib/abs_call.casl with 100% similarity]
as/casl2lib_test/abs_call1.casl [moved from as/casl2lib/abs_call1.casl with 100% similarity]
as/casl2lib_test/count1_call.casl [moved from as/casl2lib/count1_call.casl with 100% similarity]
as/casl2lib_test/count1_call0.casl [moved from as/casl2lib/count1_call0.casl with 100% similarity]
as/casl2lib_test/divl_call.casl [moved from as/casl2lib/divl_call.casl with 100% similarity]
as/casl2lib_test/divl_call0.casl [moved from as/casl2lib/divl_call0.casl with 100% similarity]
as/casl2lib_test/divl_call1.casl [moved from as/casl2lib/divl_call1.casl with 100% similarity]
as/casl2lib_test/inl_call.casl [moved from as/casl2lib/inl_call.casl with 100% similarity]
as/casl2lib_test/minim_call.casl [moved from as/casl2lib/minim_call.casl with 100% similarity]
as/casl2lib_test/mula_call.casl [moved from as/casl2lib/mula_call.casl with 100% similarity]
as/casl2lib_test/mula_call0.casl [moved from as/casl2lib/mula_call0.casl with 100% similarity]
as/casl2lib_test/mula_call1.casl [moved from as/casl2lib/mula_call1.casl with 100% similarity]
as/casl2lib_test/mula_call2.casl [moved from as/casl2lib/mula_call2.casl with 100% similarity]
as/casl2lib_test/mull_call.casl [moved from as/casl2lib/mull_call.casl with 100% similarity]
as/casl2lib_test/mull_call0.casl [moved from as/casl2lib/mull_call0.casl with 100% similarity]
as/casl2lib_test/mull_call1.casl [moved from as/casl2lib/mull_call1.casl with 100% similarity]
as/casl2lib_test/outa_call.casl [moved from as/casl2lib/outa_call.casl with 100% similarity]
as/casl2lib_test/outa_call1.casl [moved from as/casl2lib/outa_call1.casl with 100% similarity]
as/casl2lib_test/outa_call2.casl [moved from as/casl2lib/outa_call2.casl with 100% similarity]
as/casl2lib_test/outb_call.casl [moved from as/casl2lib/outb_call.casl with 100% similarity]
as/casl2lib_test/outd_q15_call.casl [moved from as/casl2lib/outd_q15_call.casl with 100% similarity]
as/casl2lib_test/outd_q15_call0.casl [moved from as/casl2lib/outd_q15_call0.casl with 100% similarity]
as/casl2lib_test/outl_call.casl [moved from as/casl2lib/outl_call.casl with 100% similarity]
as/casl2lib_test/outl_call0.casl [moved from as/casl2lib/outl_call0.casl with 100% similarity]
as/casl2lib_test/outl_call1.casl [moved from as/casl2lib/outl_call1.casl with 100% similarity]
as/casl2lib_test/outl_call2.casl [moved from as/casl2lib/outl_call2.casl with 100% similarity]
as/casl2lib_test/rev_call.casl [moved from as/casl2lib/rev_call.casl with 100% similarity]
as/casl2lib_test/sum_call.casl [moved from as/casl2lib/sum_call.casl with 90% similarity]
as/misc/count1.casl [new file with mode: 0644]
as/misc/iotest.casl [moved from as/casl2lib/iotest.casl with 50% similarity]
as/misc/mula0.casl [moved from as/casl2lib/mula0.casl with 100% similarity]
as/misc/mula_timestab.casl [moved from as/casl2lib/mula_timestab.casl with 100% similarity]
as/misc/mull0.casl [moved from as/casl2lib/mull0.casl with 100% similarity]
as/misc/mull_timestab.casl [moved from as/casl2lib/mull_timestab.casl with 100% similarity]
as/misc/sum_10.casl [moved from as/casl2lib/sum_10.casl with 100% similarity]
as/misc/sum_10_2.casl [moved from as/casl2lib/sum_10_2.casl with 100% similarity]
test/integration/casl2/minim_call/Makefile

diff --git a/as/casl2lib/count1.casl b/as/casl2lib/count1.casl
deleted file mode 100644 (file)
index 41f8d57..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-COUNT1 START
-;       入力    GR1:検索する語
-;       処理    GR1中の'1'のビットの個数を求める
-;       出力    GR0:GR1中の'1'のビットの個数
-       PUSH    0,GR1
-    PUSH       0,GR2
-    SUBA       GR2,GR2
-    AND                GR1,GR1
-    JZE        RETURN
-MORE LAD       GR2,1,GR2
-       LAD             GR0,-1,GR1
-    AND                GR1,GR0
-    JNZ                MORE
-RETURN LD      GR0,GR2
-       POP             GR2
-    POP                GR1
-    RET
-    END
index f1198da..32ff6c0 100644 (file)
@@ -1,10 +1,13 @@
-;;; GR1のアドレスに格納されたGR2の個数の値の中で、最小値をGR0に格納する
+;;; 複数のWORD値の中から、最小値を返す
+;;; 入力: GR1: WORD値を格納したアドレス GR2: 値の個数
+;;; 出力: GR0: 最小値
 MINIM   START
+        RPUSH
         LD      GR0,0,GR1
         ST      GR0,MIN
         LAD     GR3,0
 S1      CPA     GR3,GR2
-        JZE     LRET
+        JZE     RET
         LAD     GR1,1,GR1
         LD      GR0,0,GR1
         CPA     GR0,MIN
@@ -13,7 +16,8 @@ S1      CPA     GR3,GR2
         ST      GR0,MIN
 S2      LAD     GR3,1,GR3
         JUMP    S1
-LRET    LD      GR0,MIN
+RET     LD      GR0,MIN
+        RPOP
         RET
 MIN     DS      1
         END
similarity index 100%
rename from as/casl2lib/mula2.casl
rename to as/casl2lib/mula.casl
diff --git a/as/casl2lib/mula1.casl b/as/casl2lib/mula1.casl
deleted file mode 100644 (file)
index 8633b15..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-;;; -32767〜32767の範囲にある正数のかけ算(筆算方式)を行う
-;;; 入力 GR1:被乗数 GR2:乗数
-;;; 出力 GR0:積
-;;; 被乗数または乗数が-32768の場合は、オーバーフロー
-;;; 積が-32767未満または32767より大きい場合は、GR0は積の下位16ビットになり、オーバーフロー
-MULA    START
-        RPUSH
-        XOR     GR0,GR0         ; 積
-        AND     GR1,GR1         ; (GR1 = 0)の場合、終了
-        JZE     FIN             ; ↓
-        AND     GR2,GR2         ; (GR2 = 0)の場合、終了
-        JZE     FIN             ; ↓
-        LAD     GR3,1           ; 対象ビット
-        XOR     GR4,GR4         ; マイナスフラグ
-CHK1    AND     GR1,GR1         ; (GR1 > 0)の場合は、CHK2へジャンプ
-        JPL     CHK2            ; ↓
-        XOR     GR1,ALLON       ; GR1の正負を反転
-        ADDA    GR1,ONE         ; ↓
-        JOV     FIN             ; (GR1 = -32768)の場合は終了
-        XOR     GR4,ONE         ; GR4 <- 1
-CHK2    AND     GR2,GR2         ; (GR1 > 0)の場合は、LOOPへジャンプ
-        JPL     LOOP            ; ↓
-        XOR     GR2,ALLON       ; GR2の正負を反転
-        ADDA    GR2,ONE         ; ↓
-        JOV     FIN             ; (GR2 = -32768)の場合は終了
-        XOR     GR4,ONE         ; マイナスフラグを反転
-LOOP    PUSH    0,GR3           ; ループ先頭。GR2のビット中でGR3の示したものが0の場合、NEXTへジャンプ
-        AND     GR3,GR2         ; ↓
-        POP     GR3             ; ↓
-        JZE     NEXT            ; ↓
-        ADDA    GR0,GR1         ; GR0 <- GR0 + GR1
-        JOV     FIN             ; オーバーフローした場合、終了
-NEXT    SLA     GR3,1           ; GR3を1回左シフト
-        AND     GR3,GR3         ; (GR3 = 0)の場合、ループ脱出
-        JZE     MIN             ; ↓
-        CPL     GR3,GR2         ; (GR3 > GR2)の場合、ループ脱出
-        JPL     MIN             ; ↓
-        SLA     GR1,1           ; GR1を1回左シフト
-        JOV     FIN             ; オーバーフローした場合、終了
-        JUMP    LOOP            ; ループ終端
-MIN     AND     GR4,GR4         ; マイナスフラグがオフの場合、終了
-        JZE     FIN             ; ↓
-        XOR     GR0,ALLON       ; GR1の正負を反転
-        ADDA    GR0,ONE         ; ↓
-FIN     RPOP
-        RET
-ONE     DC      1
-ALLON   DC      #FFFF
-        END
similarity index 100%
rename from as/casl2lib/mull1.casl
rename to as/casl2lib/mull.casl
diff --git a/as/casl2lib/outa0.casl b/as/casl2lib/outa0.casl
deleted file mode 100644 (file)
index 1087f6c..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-;;; GR1に格納された値を、10進数の整数値(-32768〜32767)として表示
-OUTA    START
-        RPUSH
-        LAD     GR2,10          ; GR2に10進数の「10」を格納。
-        LAD     GR0,0           ; GR0 <- 0
-        LAD     GR4,0           ; 負数フラグ。GR1が負数の場合、GR4は1
-        ST      GR0,LEN         ; LENの初期化
-        AND     GR1,GR1         ; GR1をテスト
-        JZE     ZPRT            ; GR1が0の場合、ZPRTにジャンプ
-        JPL     STI             ; GR1が正数の場合、STIにジャンプ
-        LAD     GR4,1           ; GR1が負数の場合、GR4をオン
-        CALL    OABS            ;                  GR1を正数に変換
-STI     CPL     GR1,GR2         ; ループ先頭。(GR1 < GR2)の場合は、ループ脱出
-        JMI     STLST           ; ↓
-        CALL    ODIVL           ; GR1とGR2の、商をGR0、剰余をGR3に格納
-        LD      GR1,GR3         ; GR1にGR3をコピー
-        LD      GR1,NCHAR,GR1   ; GR1を文字に変換
-        CALL    STSTR           ; GR1をSTR領域に格納
-        LD      GR1,GR0         ; GR0をGR1にコピー
-        JUMP    STI             ; ループ終端
-STLST   LD      GR1,NCHAR,GR1   ; GR1を文字に変換
-        CALL    STSTR           ; GR1をSTR領域に格納
-        AND     GR4,GR4         ; 正数の場合
-        JZE     PRT             ; ↓
-        LD      GR1,='-'        ; 負数の場合、「-」をSTR領域に格納
-        CALL    STSTR           ; ↓
-        JUMP    PRT             ; PRTにジャンプ
-ZPRT    LD      GR1,NCHAR       ; 「0」をSTR領域に格納
-        CALL    STSTR           ; ↓
-PRT     LD      GR2,LEN         ; GR2にLENの値を格納
-        LAD     GR1,STR         ; GR1に文字列のアドレスを格納
-        CALL    REV             ; 文字列を逆順に並べ替え
-        OUT     STR,LEN         ; 文字列を出力
-        RPOP
-        RET
-STR     DS      17
-LEN     DS      1
-NCHAR   DC      '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-        END
-;; GR1をSTR領域に格納し、LENをインクリメント
-STSTR   START
-        PUSH    0,GR1
-        PUSH    0,GR2
-        LD      GR2,LEN         ; GR2にLENの値をロード
-        ST      GR1,STR,GR2     ; STR+GR2 <- GR1
-        LAD     GR2,1,GR2       ; GR2 <- GR2 + 1
-        ST      GR2,LEN         ; LENにGR2を格納
-        POP     GR2
-        POP     GR1
-        RET
-        END
-;;; GR1の値とGR2の値の、商をGR0、剰余をGR3に格納する
-;;; 0〜65535の範囲の数値を扱う
-ODIVL   START
-        PUSH    0,GR1
-        AND     GR2,GR2         ; (GR2 = 0)の場合、ODYZへジャンプ
-        JZE     ODYZ            ; ↓
-        LAD     GR0,0           ; GR0を初期化
-        LD      GR3,GR1         ; GR3 <- GR1
-ODLOOP  CPL     GR3,GR2         ; ループ先頭。(GR3 < GR2)の場合、終了
-        JMI     ODFIN           ; ↓
-        SUBL    GR3,GR2         ; GR3 <- GR3 - GR2
-        ADDL    GR0,ODONE       ; ↓
-        JUMP    ODLOOP          ; ループ終端
-ODYZ    LAD     GR3,#FFFF       ; 強制的にオーバーフローを発生させ、GR3 <- 0
-        ADDL    GR3,=1          ; ↓
-        JUMP    ODFIN           ; ODFINへジャンプ
-ODFIN   POP     GR1
-        RET
-ODONE   DC      1        
-        END
-;; アドレスがGR1、長さがGR2の文字列を逆順に並べ替える
-;; 例: 12345 -> 54321、54321- -> -12345
-REV     START
-        RPUSH
-        LAD     GR3,0           ; GR3の初期化
-RPU     CPL     GR3,GR2         ; ループ先頭。(GR3 = GR2)の場合、ループ脱出
-        JZE     RNEXT           ; ↓
-        LD      GR4,GR1         ; GR4にGR1の値をコピー
-        ADDL    GR4,GR3         ; GR4 <- GR4 + GR3
-        LD      GR5,0,GR4       ; GR5にアドレスGR4の値を格納
-        PUSH    0,GR5           ; GR5をプッシュ
-        LAD     GR3,1,GR3       ; GR3 <- GR3 + 1
-        JUMP    RPU             ; ループ終端
-RNEXT   LAD     GR3,0           ; GR3の初期化
-RPO     CPL     GR3,GR2         ; ループ先頭。(GR3 = GR2)の場合、ループ脱出
-        JZE     RFIN            ; ↓
-        POP     GR5             ; GR5にポップ
-        LD      GR4,GR1         ; GR4にGR1の値をコピー
-        ADDL    GR4,GR3         ; GR4 <- GR4 + GR3
-        ST      GR5,0,GR4       ; アドレスGR4にGR5の値を格納
-        LAD     GR3,1,GR3       ; GR3 <- GR3 + 1
-        JUMP    RPO             ; ループ終端
-RFIN    RPOP
-        RET
-        END
-;; GR1の値を絶対値に変換する。GR1にはマイナスの数値が格納されていると想定。
-;; 例: -10 -> 10, -20 -> 20
-OABS    START
-        XOR     GR1,=#FFFF      ; GR1の値を反転
-        LAD     GR1,1,GR1       ; GR1 <- GR1 + 1
-        RET
-        END
index b9bfe11..0121134 100644 (file)
@@ -1,16 +1,16 @@
 ;;; sum.casl
 ;;; 入力 GR1: 1以上の正数
-;;; 出力 GR2: 1からGR1で指定された値までの正数をすべて加算した値。
-;;;           オーバーフローした場合は、#FFFF
+;;; 出力 GR0: 1からGR1で指定された値までの正数をすべて加算した値。
+;;;           オーバーフローした場合は、0
 SUM     START
-        LAD     GR2,0
-        LAD     GR3,1
-LOOP    CPL     GR3,GR1
+        LAD     GR0,0
+        LAD     GR2,1
+LOOP    CPL     GR2,GR1
         JPL     FIN
-        ADDL    GR2,GR3
+        ADDL    GR0,GR2
         JOV     OV
-        LAD     GR3,1,GR3
+        LAD     GR2,1,GR2
         JUMP    LOOP
-OV      LAD     GR2,#FFFF
+OV      LAD     GR0,0
 FIN     RET
         END
similarity index 90%
rename from as/casl2lib/sum_call.casl
rename to as/casl2lib_test/sum_call.casl
index a983623..eea0111 100644 (file)
@@ -3,7 +3,7 @@
 MAIN    START
         LAD     GR1,361
         CALL    SUM
-        LD      GR1,GR2
+        LD      GR1,GR0
         CALL    OUTL
 MFIN    RET
         END
diff --git a/as/misc/count1.casl b/as/misc/count1.casl
new file mode 100644 (file)
index 0000000..52e6b03
--- /dev/null
@@ -0,0 +1,19 @@
+;;; 「アセンブラ言語の使用」に掲載されているサンプル
+COUNT1  START
+;       入力    GR1:検索する語
+;       処理    GR1中の'1'のビットの個数を求める
+;       出力    GR0:GR1中の'1'のビットの個数
+        PUSH    0,GR1           ;
+        PUSH    0,GR2           ;
+        SUBA    GR2,GR2         ; Count = 0
+        AND     GR1,GR1         ; 全部のビットが'0'?
+        JZE     RETURN          ; 全部のビットが'0'なら終了
+MORE    LAD     GR2,1,GR2       ; Count = Count + 1
+        LAD     GR0,-1,GR1      ; 最下位の'1'のビット1個を
+        AND     GR1,GR0         ;  '0'に変える
+        JNZ     MORE            ; '1'のビットが残っていれば繰返し
+RETURN  LD      GR0,GR2         ; GR0 = Count
+        POP     GR2             ;
+        POP     GR1             ;
+        RET                     ; 呼び出しプログラムへ戻る
+        END                     ;
similarity index 50%
rename from as/casl2lib/iotest.casl
rename to as/misc/iotest.casl
index af25ff3..fe5f553 100644 (file)
@@ -1,13 +1,13 @@
 IOTEST  START
-           OUT     OBUF1,OLEN1
+        OUT     OBUF1,OLEN1
 LOOP    IN      IOBUF,IOLEN
-           LD      GR1,IOLEN
-        JZE        RETURN
-           OUT     OBUF2,OLEN2
-           OUT     IOBUF,IOLEN
-           OUT     OBUF3,OLEN3
-           JUMP    LOOP
-RETURN RET
+        LD      GR1,IOLEN
+        JZE     RETURN
+        OUT     OBUF2,OLEN2
+        OUT     IOBUF,IOLEN
+        OUT     OBUF3,OLEN3
+        JUMP    LOOP
+RETURN  RET
 ; Memory
 OBUF1   DC      'LET''S START. TYPE IN'
 OLEN1   DC      20
@@ -16,5 +16,5 @@ OLEN2   DC      9
 OBUF3   DC      'WHAT''S NEXT?'
 OLEN3   DC      12
 IOBUF   DS      64
-IOLEN   DS      1   
-           END
+IOLEN   DS      1
+        END
similarity index 100%
rename from as/casl2lib/mula0.casl
rename to as/misc/mula0.casl
similarity index 100%
rename from as/casl2lib/mull0.casl
rename to as/misc/mull0.casl
similarity index 100%
rename from as/casl2lib/sum_10.casl
rename to as/misc/sum_10.casl
index ba0159d..b0bf0c6 100644 (file)
@@ -1,5 +1,6 @@
 include ../CMD.mk    # YACASL2DIR, CASL2
-ASDIR = $(YACASL2DIR)/as/FUNC
-ASFILE = $(ASDIR)/minim_call.casl $(ASDIR)/minim.casl $(ASDIR)/outa.casl
+ASDIR = $(YACASL2DIR)/as/casl2lib_test
+LIBDIR = $(YACASL2DIR)/as/casl2lib
+ASFILE = $(ASDIR)/minim_call.casl $(LIBDIR)/minim.casl $(LIBDIR)/outa.casl
 CMD = $(CASL2) $(ASFILE)
 include ../TEST.mk