--- /dev/null
+outl.casl: outl_main.casl divl1.casl rev.casl
+ cat $^ >$@
+outa.casl: outa_main.casl divl1.casl rev.casl abs.casl
+ cat $^ >$@
+outb.casl: outb_main.casl divl1.casl rev.casl
+ cat $^ >$@
;;; GR1を絶対値に変換する
ABS START
AND GR1,GR1
- JPL ABSFIN
- JZE ABSFIN
+ JPL FIN
+ JZE FIN
XOR GR1,=#FFFF
- LAD GR1,1,GR1
-ABSFIN RET
+ ADDA GR1,=1
+FIN RET
END
--- /dev/null
+;;; 2つの32ビット数値を加算する
+;;; 32ビットの値は、連続する2語の領域に格納
+MAIN START BEGIN
+BEGIN LAD GR1,1 ; GR1にAの下位語を転送
+ LD GR1,A,GR1 ; ↓
+ LAD GR2,1 ; GR2にBの下位語を転送
+ LD GR2,B,GR2 ; ↓
+ ADDL GR1,GR2 ; GR1 <- GR1 + GR2
+ JOV CARR ; オーバーフロー時は、CARRにジャンプ
+ JUMP STL
+CARR LAD GR2,1 ; Cの上位語に1を格納
+ ST GR2,C ; ↓
+STL LAD GR2,1 ; Cの下位語にGR1の内容を格納
+ ST GR1,C,GR2 ; ↓
+ LD GR1,A ; GR1にAの上位語を転送
+ ADDL GR1,B ; GR1 <- GR1 + B
+ ADDL GR1,C ; GR1 <- GR1 + C
+ RET
+A DC 0,65534
+B DC 0,65535
+C DS 2
+ END
-;;; GR1の値とGR2の値の、商をGR0、剰余をGR3に格納する
-;;; 0〜65535の範囲の数値を扱う
+;;; 0〜65535の範囲にある正数の割算を行う
+;;; 入力 GR1:被除数 GR2:除数
+;;; 出力 GR0:商 GR3:剰余
+;;; GR2が0の場合は、GR0、GR3とも0になり、オーバーフロー
DIVL START
PUSH 0,GR1
AND GR2,GR2 ; (GR2 = 0)の場合、DYZへジャンプ
- JZE DYZ ; ↓
+ JZE DIVZERO ; ↓
LAD GR0,0 ; GR0を初期化
LD GR3,GR1 ; GR3 <- GR1
-DLOOP CPL GR3,GR2 ; ループ先頭。(GR3 < GR2)の場合、終了
- JMI DFIN ; ↓
+LOOP CPL GR3,GR2 ; ループ先頭。(GR3 < GR2)の場合、終了
+ JMI FIN ; ↓
SUBL GR3,GR2 ; GR3 <- GR3 - GR2
- ADDL GR0,DONE ; ↓
- JUMP DLOOP ; ループ終端
-DYZ LAD GR3,#FFFF ; 強制的にオーバーフローを発生させ、GR3 <- 0
- ADDL GR3,=1 ; ↓
- JUMP DFIN ; DFINへジャンプ
-DFIN POP GR1
+ ADDL GR0,ONE ; ↓
+ JUMP LOOP ; ループ終端
+DIVZERO LAD GR3,#8000 ; 強制的にオーバーフローを発生させ、GR3 <- 0
+ SLL GR3,1 ; ↓
+ JUMP FIN ; FIN へジャンプ
+FIN POP GR1
RET
-DONE DC 1
+ONE DC 1
END
PUSH 0,GR1
PUSH 0,GR2
PUSH 0,GR4
- AND GR2,GR2 ; (GR2 = 0)の場合、DFZへジャンプ
- JZE DYZ ; ↓
- ST GR2,DY ; DYにGR2の初期値を保存
+ AND GR2,GR2 ; (GR2 = 0)の場合、DIVZEROへジャンプ
+ JZE DIVZERO ; ↓
+ ST GR2,Y ; YにGR2の初期値を保存
LAD GR0,0 ; GR0の初期化
LAD GR3,0 ; GR3の初期化
LAD GR4,1 ; GR4の初期化。対象ビットを表す
-DSL CPL GR2,GR1 ; ループ先頭。(GR2 > GR1)の場合、DLOOPへループ脱出
- JPL DLOOP ; ↓
+SL CPL GR2,GR1 ; ループ先頭。(GR2 > GR1)の場合、LOOPへループ脱出
+ JPL LOOP ; ↓
SLL GR4,1 ; GR4を1回左シフト
+ ST GR2,TMP ; GR2の値をTMPに退避
SLL GR2,1 ; GR2を1回左シフト
- JOV DYOV ; オーバーフローの場合は、DYOVにジャンプ
- JUMP DSL ; ループ終端
-DYOV SRL GR2,1
- LAD GR2,#8000,GR2
- SRL GR4,1
- JUMP DLPIN
-DLOOP SRL GR4,1 ; ループ先頭。GR4を1回右シフト
- JZE DCP ; (GR4 = 0)の場合、ループ脱出
+ JOV YOV ; オーバーフローの場合は、YOVへジャンプ
+ JUMP SL ; ループ終端
+YOV LD GR2,TMP ; GR2の値をTMPから復元
+ SRL GR4,1 ; GR4を1回右シフト
+ JUMP LPIN ; LPINへジャンプ
+LOOP SRL GR4,1 ; ループ先頭。GR4を1回右シフト
+ JZE SETMOD ; (GR4 = 0)の場合、SETMODへループ脱出
SRL GR2,1 ; GR2を1回右シフト
- CPL GR1,DY ; (GR1 < DY)の場合、ループ脱出
- JMI DCP ; ↓
+ CPL GR1,Y ; (GR1 < Y)の場合、SETMODへループ脱出
+ JMI SETMOD ; ↓
CPL GR1,GR2 ; (GR1 < GR2)の場合、ループ先頭へジャンプ
- JMI DLOOP ; ↓
-DLPIN SUBL GR1,GR2 ; GR1 <- GR1 - GR2
+ JMI LOOP ; ↓
+LPIN SUBL GR1,GR2 ; GR1 <- GR1 - GR2
ADDL GR0,GR4 ; GR0 <- GR0 + GR4
- JUMP DLOOP ; ループ終端
-DYZ LAD GR3,#FFFF ; 強制的にオーバーフローを発生させ、GR3 <- 0
- ADDL GR3,=1 ; ↓
- JUMP DFIN ; DFINへジャンプ
-DCP LD GR3,GR1
-DFIN POP GR4
+ JUMP LOOP ; ループ終端
+DIVZERO LAD GR3,#8000 ; 強制的にオーバーフローを発生させ、GR3 <- 0
+ SLL GR3,1 ; ↓
+ JUMP FIN ; FIN へジャンプ
+SETMOD LD GR3,GR1 ; GR3 <- GR1。剰余の設定
+FIN POP GR4
POP GR2
POP GR1
RET
-DY DS 1
+Y DS 1
+TMP DS 1
END
-;GR1の値とGR2の値の積をGR0に格納
+;;; GR1の値とGR2の値の積をGR0に格納
MULL START
RPUSH
XOR GR0,GR0 ; 積
- LAD GR3,1 ; 対象ビット
-MLOOP PUSH 0,GR3 ; ループ先頭。GR2の、GR3が示したビットが0の場合、MNEXTへジャンプ
- AND GR3,GR2 ; ↓
- POP GR3 ; ↓
- JZE MNEXT ; ↓
+ LAD GR4,1 ; 対象ビット
+LOOP PUSH 0,GR4 ; ループ先頭。GR2の、GR4が示したビットが0の場合、NEXTへジャンプ
+ AND GR4,GR2 ; ↓
+ POP GR4 ; ↓
+ JZE NEXT ; ↓
ADDL GR0,GR1 ; GR0 <- GR0 + GR1
- JOV MFIN ; オーバーフローした場合、ループ脱出
-MNEXT SLL GR3,1 ; GR3を1回左シフト
- AND GR3,GR3 ; (GR3 = 0)の場合、ループ脱出
- JZE MFIN ; ↓
- CPL GR3,GR2 ; (GR3 > GR2)の場合、ループ脱出
- JPL MFIN ; ↓
+ JOV FIN ; オーバーフローした場合、OVPへジャンプ
+NEXT SLL GR4,1 ; GR4を1回左シフト
+ AND GR4,GR4 ; (GR4 = 0)の場合、ループ脱出
+ JZE FIN ; ↓
+ CPL GR4,GR2 ; (GR4 > GR2)の場合、ループ脱出
+ JPL FIN ; ↓
SLL GR1,1 ; GR1を1回左シフト
- JOV MFIN ; オーバーフローした場合、ループ脱出
- JUMP MLOOP ; ループ終端
-MFIN RPOP
+ JOV FIN ; オーバーフローした場合、ループ脱出
+ JUMP LOOP ; ループ終端
+OVP ADDL GR3,=1
+ JUMP NEXT
+FIN RPOP
RET
END
JZE ZPRT ; GR1が0の場合、ZPRTにジャンプ
JPL STI ; GR1が正数の場合、STIにジャンプ
LAD GR4,1 ; GR1が負数の場合、GR4をオン
- CALL OABS ; GR1を正数に変換
+ CALL ABS ; GR1を正数に変換
STI CPL GR1,GR2 ; ループ先頭。(GR1 < GR2)の場合は、ループ脱出
JMI STLST ; ↓
- CALL ODIVL ; GR1とGR2の、商をGR0、剰余をGR3に格納
+ CALL DIVL ; GR1とGR2の、商をGR0、剰余をGR3に格納
LD GR1,GR3 ; GR1にGR3をコピー
LD GR1,NCHAR,GR1 ; GR1を文字に変換
ST GR1,STR,GR5 ; (STR + GR5) <- GR1
LEN DS 1
NCHAR DC '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
END
-;;; GR1の値とGR2の値の、商をGR0、剰余をGR3に格納する
-;;; 0〜65535の範囲の数値を扱う
-ODIVL START
+;;; 0〜65535の範囲にある正数の割算(筆算方式)を行う
+;;; 入力 GR1:被除数 GR2:除数
+;;; 出力 GR0:商 GR3:剰余
+;;; GR2が0の場合は、GR0、GR3とも0になり、オーバーフロー
+DIVL START
PUSH 0,GR1
PUSH 0,GR2
PUSH 0,GR4
- AND GR2,GR2 ; GR2が0の場合、ODFINへジャンプ
- JZE ODFIN ; ↓
- ST GR2,ODY ; ODYにGR2の初期値を保存
+ AND GR2,GR2 ; (GR2 = 0)の場合、DIVZEROへジャンプ
+ JZE DIVZERO ; ↓
+ ST GR2,Y ; YにGR2の初期値を保存
LAD GR0,0 ; GR0の初期化
LAD GR3,0 ; GR3の初期化
LAD GR4,1 ; GR4の初期化。対象ビットを表す
-ODSL CPL GR2,GR1 ; ループ先頭。(GR2 > GR1)の場合、ODLOOPへループ脱出
- JPL ODLOOP ; ↓
+SL CPL GR2,GR1 ; ループ先頭。(GR2 > GR1)の場合、LOOPへループ脱出
+ JPL LOOP ; ↓
SLL GR4,1 ; GR4を1回左シフト
+ ST GR2,TMP ; GR2の値をTMPに退避
SLL GR2,1 ; GR2を1回左シフト
- JOV ODYOV ; オーバーフローの場合は、ODYOVにジャンプ
- JUMP ODSL ; ループ終端
-ODYOV SRL GR2,1
- LAD GR2,#8000,GR2
- SRL GR4,1
- JUMP ODLPIN
-ODLOOP SRL GR4,1 ; ループ先頭。GR4を1回右シフト
- JZE ODFIN ; (GR4 = 0)の場合、ループ脱出
+ JOV YOV ; オーバーフローの場合は、YOVへジャンプ
+ JUMP SL ; ループ終端
+YOV LD GR2,TMP ; GR2の値をTMPから復元
+ SRL GR4,1 ; GR4を1回右シフト
+ JUMP LPIN ; LPINへジャンプ
+LOOP SRL GR4,1 ; ループ先頭。GR4を1回右シフト
+ JZE SETMOD ; (GR4 = 0)の場合、SETMODへループ脱出
SRL GR2,1 ; GR2を1回右シフト
- CPL GR1,ODY ; (GR1 < ODY)の場合、ループ脱出
- JMI ODFIN ; ↓
+ CPL GR1,Y ; (GR1 < Y)の場合、SETMODへループ脱出
+ JMI SETMOD ; ↓
CPL GR1,GR2 ; (GR1 < GR2)の場合、ループ先頭へジャンプ
- JMI ODLOOP ; ↓
-ODLPIN SUBL GR1,GR2 ; GR1 <- GR1 - GR2
+ JMI LOOP ; ↓
+LPIN SUBL GR1,GR2 ; GR1 <- GR1 - GR2
ADDL GR0,GR4 ; GR0 <- GR0 + GR4
- JUMP ODLOOP ; ループ終端
-ODFIN LD GR3,GR1
- POP GR4
+ JUMP LOOP ; ループ終端
+DIVZERO LAD GR3,#8000 ; 強制的にオーバーフローを発生させ、GR3 <- 0
+ SLL GR3,1 ; ↓
+ JUMP FIN ; FIN へジャンプ
+SETMOD LD GR3,GR1
+FIN POP GR4
POP GR2
POP GR1
RET
-ODY DS 1
+Y DS 1
+TMP DS 1
END
;; アドレスがGR1、長さがGR2の文字列を逆順に並べ替える
;; 例: 12345 -> 54321、54321- -> -12345
REV START
RPUSH
LAD GR3,0 ; GR3の初期化
-RPU CPL GR3,GR2 ; ループ先頭。(GR3 = GR2)の場合、ループ脱出
- JZE RNEXT ; ↓
+PU CPL GR3,GR2 ; ループ先頭。(GR3 = GR2)の場合、ループ脱出
+ JZE NEXT ; ↓
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 ; ↓
+ JUMP PU ; ループ終端
+NEXT LAD GR3,0 ; GR3の初期化
+PO CPL GR3,GR2 ; ループ先頭。(GR3 = GR2)の場合、ループ脱出
+ JZE FIN ; ↓
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
+ JUMP PO ; ループ終端
+FIN RPOP
RET
END
-;; GR1の値を絶対値に変換する。GR1にはマイナスの数値が格納されていると想定。
-;; 例: -10 -> 10, -20 -> 20
-OABS START
- XOR GR1,=#FFFF ; GR1の値を反転
- LAD GR1,1,GR1 ; GR1 <- GR1 + 1
- RET
+;;; GR1を絶対値に変換する
+ABS START
+ AND GR1,GR1
+ JPL FIN
+ JZE FIN
+ XOR GR1,=#FFFF
+ ADDA GR1,=1
+FIN RET
END
--- /dev/null
+;;; GR1に格納された値を、10進数の整数値(-32768〜32767)として表示
+OUTA START
+ RPUSH
+ LAD GR2,10 ; GR2に10進数の「10」を格納。
+ LAD GR0,0 ; GR0 <- 0
+ LAD GR4,0 ; 負数フラグ。GR1が負数の場合、GR4は1
+ LAD GR5,0 ; 整数値の長さ
+ AND GR1,GR1 ; GR1をテスト
+ JZE ZPRT ; GR1が0の場合、ZPRTにジャンプ
+ JPL STI ; GR1が正数の場合、STIにジャンプ
+ LAD GR4,1 ; GR1が負数の場合、GR4をオン
+ CALL ABS ; GR1を正数に変換
+STI CPL GR1,GR2 ; ループ先頭。(GR1 < GR2)の場合は、ループ脱出
+ JMI STLST ; ↓
+ CALL DIVL ; GR1とGR2の、商をGR0、剰余をGR3に格納
+ LD GR1,GR3 ; GR1にGR3をコピー
+ LD GR1,NCHAR,GR1 ; GR1を文字に変換
+ ST GR1,STR,GR5 ; (STR + GR5) <- GR1
+ LAD GR5,1,GR5 ; GR5 <- GR5 + 1
+ LD GR1,GR0 ; GR0をGR1にコピー
+ JUMP STI ; ループ終端
+STLST LD GR1,NCHAR,GR1 ; GR1を文字に変換
+ ST GR1,STR,GR5 ; (STR + GR5) <- GR1
+ LAD GR5,1,GR5 ; GR5 <- GR5 + 1
+ AND GR4,GR4 ; 正数の場合
+ JZE PRT ; ↓
+ LD GR1,='-' ; 負数の場合、「-」をSTR領域に格納
+ ST GR1,STR,GR5 ; (STR + GR5) <- GR1
+ LAD GR5,1,GR5 ; GR5 <- GR5 + 1
+ JUMP PRT ; PRTにジャンプ
+ZPRT LD GR1,NCHAR ; 「0」をSTR領域に格納
+ ST GR1,STR,GR5 ; (STR + GR5) <- GR1
+ LAD GR5,1,GR5 ; GR5 <- GR5 + 1
+PRT ST GR5,LEN ; LEN <- GR5
+ 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
JZE ZERO ; GR1が0の場合、ZEROにジャンプ
STI CPL GR1,GR2 ; ループ先頭。(GR1 < GR2)の場合は、ループ脱出
JMI STLST ; ↓
- CALL ODIVL ; GR1とGR2の、商をGR0、剰余をGR3に格納
+ CALL DIVL ; GR1とGR2の、商をGR0、剰余をGR3に格納
LD GR1,GR3 ; GR1にGR3をコピー
LD GR1,NCHAR,GR1 ; GR1を文字に変換
ST GR1,STR,GR4 ; (STR + GR4) <- GR1
NCHAR DC '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
DIG DC 16
END
-;;; GR1の値とGR2の値の、商をGR0、剰余をGR3に格納する
-;;; 0〜65535の範囲の数値を扱う
-ODIVL START
+;;; 0〜65535の範囲にある正数の割算(筆算方式)を行う
+;;; 入力 GR1:被除数 GR2:除数
+;;; 出力 GR0:商 GR3:剰余
+;;; GR2が0の場合は、GR0、GR3とも0になり、オーバーフロー
+DIVL START
PUSH 0,GR1
PUSH 0,GR2
PUSH 0,GR4
- AND GR2,GR2 ; GR2が0の場合、ODFINへジャンプ
- JZE ODFIN ; ↓
- ST GR2,ODY ; ODYにGR2の初期値を保存
+ AND GR2,GR2 ; (GR2 = 0)の場合、DIVZEROへジャンプ
+ JZE DIVZERO ; ↓
+ ST GR2,Y ; YにGR2の初期値を保存
LAD GR0,0 ; GR0の初期化
LAD GR3,0 ; GR3の初期化
LAD GR4,1 ; GR4の初期化。対象ビットを表す
-ODSL CPL GR2,GR1 ; ループ先頭。(GR2 > GR1)の場合、ODLOOPへループ脱出
- JPL ODLOOP ; ↓
+SL CPL GR2,GR1 ; ループ先頭。(GR2 > GR1)の場合、LOOPへループ脱出
+ JPL LOOP ; ↓
SLL GR4,1 ; GR4を1回左シフト
+ ST GR2,TMP ; GR2の値をTMPに退避
SLL GR2,1 ; GR2を1回左シフト
- JOV ODYOV ; オーバーフローの場合は、ODYOVにジャンプ
- JUMP ODSL ; ループ終端
-ODYOV SRL GR2,1
- LAD GR2,#8000,GR2
- SRL GR4,1
- JUMP ODLPIN
-ODLOOP SRL GR4,1 ; ループ先頭。GR4を1回右シフト
- JZE ODFIN ; (GR4 = 0)の場合、ループ脱出
+ JOV YOV ; オーバーフローの場合は、YOVへジャンプ
+ JUMP SL ; ループ終端
+YOV LD GR2,TMP ; GR2の値をTMPから復元
+ SRL GR4,1 ; GR4を1回右シフト
+ JUMP LPIN ; LPINへジャンプ
+LOOP SRL GR4,1 ; ループ先頭。GR4を1回右シフト
+ JZE SETMOD ; (GR4 = 0)の場合、SETMODへループ脱出
SRL GR2,1 ; GR2を1回右シフト
- CPL GR1,ODY ; (GR1 < ODY)の場合、ループ脱出
- JMI ODFIN ; ↓
+ CPL GR1,Y ; (GR1 < Y)の場合、SETMODへループ脱出
+ JMI SETMOD ; ↓
CPL GR1,GR2 ; (GR1 < GR2)の場合、ループ先頭へジャンプ
- JMI ODLOOP ; ↓
-ODLPIN SUBL GR1,GR2 ; GR1 <- GR1 - GR2
+ JMI LOOP ; ↓
+LPIN SUBL GR1,GR2 ; GR1 <- GR1 - GR2
ADDL GR0,GR4 ; GR0 <- GR0 + GR4
- JUMP ODLOOP ; ループ終端
-ODFIN LD GR3,GR1
- POP GR4
+ JUMP LOOP ; ループ終端
+DIVZERO LAD GR3,#8000 ; 強制的にオーバーフローを発生させ、GR3 <- 0
+ SLL GR3,1 ; ↓
+ JUMP FIN ; FIN へジャンプ
+SETMOD LD GR3,GR1
+FIN POP GR4
POP GR2
POP GR1
RET
-ODY DS 1
+Y DS 1
+TMP DS 1
END
;; アドレスがGR1、長さがGR2の文字列を逆順に並べ替える
;; 例: 12345 -> 54321、54321- -> -12345
REV START
RPUSH
LAD GR3,0 ; GR3の初期化
-RPU CPL GR3,GR2 ; ループ先頭。(GR3 = GR2)の場合、ループ脱出
- JZE RNEXT ; ↓
+PU CPL GR3,GR2 ; ループ先頭。(GR3 = GR2)の場合、ループ脱出
+ JZE NEXT ; ↓
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 ; ↓
+ JUMP PU ; ループ終端
+NEXT LAD GR3,0 ; GR3の初期化
+PO CPL GR3,GR2 ; ループ先頭。(GR3 = GR2)の場合、ループ脱出
+ JZE FIN ; ↓
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
+ JUMP PO ; ループ終端
+FIN RPOP
RET
END
--- /dev/null
+;;; GR1に格納された値を、2進数値として表示
+OUTB START
+ RPUSH
+ LAD GR2,2 ; GR2に2進数の「2」を格納。
+ LAD GR0,0 ; GR0 <- 0
+ XOR GR4,GR4 ; 2進数値の長さ
+ AND GR1,GR1 ; GR1をテスト
+ JZE ZERO ; GR1が0の場合、ZEROにジャンプ
+STI CPL GR1,GR2 ; ループ先頭。(GR1 < GR2)の場合は、ループ脱出
+ JMI STLST ; ↓
+ CALL DIVL ; GR1とGR2の、商をGR0、剰余をGR3に格納
+ LD GR1,GR3 ; GR1にGR3をコピー
+ LD GR1,NCHAR,GR1 ; GR1を文字に変換
+ ST GR1,STR,GR4 ; (STR + GR4) <- GR1
+ LAD GR4,1,GR4 ; GR4 <- GR4 + 1
+ LD GR1,GR0 ; GR0をGR1にコピー
+ JUMP STI ; ループ終端
+STLST LD GR1,NCHAR,GR1 ; GR1を文字に変換
+ ST GR1,STR,GR4 ; (STR + GR4) <- GR1
+ LAD GR4,1,GR4 ; GR4 <- GR4 + 1
+ JUMP EMB ; EMBにジャンプ
+ZERO LD GR1,NCHAR ; 「0」をSTR領域に格納
+ ST GR1,STR,GR4 ; ↓ (STR + GR4) <- GR1
+ LAD GR4,1,GR4 ; ↓ GR4 <- GR4 + 1
+EMB LD GR1,NCHAR ; GR1 <- '0'
+EMLOOP CPA GR4,DIG ; ループ先頭。(GR4 = DIG)の場合は、ループ脱出
+ JZE PRT ; ↓
+ ST GR1,STR,GR4 ; ↓ (STR + GR4) <- GR1
+ LAD GR4,1,GR4 ; ↓ GR4 <- GR4 + 1
+ JUMP EMLOOP ; ループ終端
+PRT ST GR4,LEN ; LEN <- GR4
+ 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'
+DIG DC 16
+ END
LD GR5,='.' ; 「.」をSTR領域に格納
ST GR5,STR,GR4 ; ↓
LAD GR4,1,GR4 ; ↓ GR4 <- GR4 + 1
-;; GR1の内容を小数値と見なし、10進数æ\96\87å\97ã\81«å¤\89æ\8f\9bã\81\97ã\81¦STRã\81«æ ¼ç´\8d
+;; GR1の内容を小数値と見なし、10進数ã\81®æ\96\87å\97å\88\97ã\81«å¤\89æ\8f\9bã\81\97ã\81¦STRã\81«æ ¼ç´\8d
TODIG AND GR1,GR1 ; GR1が0の場合は、ループを脱出
JZE PRT ; ↓
CALL MUL ; GR1とGR2の、積をGR1、オーバーフロー値をGR3に格納
LEN DS 1
END
;; GR1の値を10倍にし、GR3にオーバーフロー値を格納
-MUL START
+MUL START
PUSH 0,GR5
PUSH 0,GR6
LAD GR3,0 ; GR3は、オーバーフロー値を格納
JZE ZERO ; GR1が0の場合、ZEROにジャンプ
STI CPL GR1,GR2 ; ループ先頭。(GR1 < GR2)の場合は、ループ脱出
JMI STLST ; ↓
- CALL ODIVL ; GR1とGR2の、商をGR0、剰余をGR3に格納
+ CALL DIVL ; GR1とGR2の、商をGR0、剰余をGR3に格納
LD GR1,GR3 ; GR1にGR3をコピー
LD GR1,NCHAR,GR1 ; GR1を文字に変換
ST GR1,STR,GR4 ; (STR + GR4) <- GR1
LEN DS 1
NCHAR DC '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
END
-;;; GR1の値とGR2の値の、商をGR0、剰余をGR3に格納する
-;;; 0〜65535の範囲の数値を扱う
-ODIVL START
+;;; 0〜65535の範囲にある正数の割算(筆算方式)を行う
+;;; 入力 GR1:被除数 GR2:除数
+;;; 出力 GR0:商 GR3:剰余
+;;; GR2が0の場合は、GR0、GR3とも0になり、オーバーフロー
+DIVL START
PUSH 0,GR1
PUSH 0,GR2
PUSH 0,GR4
- AND GR2,GR2 ; GR2が0の場合、ODFINへジャンプ
- JZE ODFIN ; ↓
- ST GR2,ODY ; ODYにGR2の初期値を保存
+ AND GR2,GR2 ; (GR2 = 0)の場合、DIVZEROへジャンプ
+ JZE DIVZERO ; ↓
+ ST GR2,Y ; YにGR2の初期値を保存
LAD GR0,0 ; GR0の初期化
LAD GR3,0 ; GR3の初期化
LAD GR4,1 ; GR4の初期化。対象ビットを表す
-ODSL CPL GR2,GR1 ; ループ先頭。(GR2 > GR1)の場合、ODLOOPへループ脱出
- JPL ODLOOP ; ↓
+SL CPL GR2,GR1 ; ループ先頭。(GR2 > GR1)の場合、LOOPへループ脱出
+ JPL LOOP ; ↓
SLL GR4,1 ; GR4を1回左シフト
+ ST GR2,TMP ; GR2の値をTMPに退避
SLL GR2,1 ; GR2を1回左シフト
- JOV ODYOV ; オーバーフローの場合は、ODYOVにジャンプ
- JUMP ODSL ; ループ終端
-ODYOV SRL GR2,1
- LAD GR2,#8000,GR2
- SRL GR4,1
- JUMP ODLPIN
-ODLOOP SRL GR4,1 ; ループ先頭。GR4を1回右シフト
- JZE ODFIN ; (GR4 = 0)の場合、ループ脱出
+ JOV YOV ; オーバーフローの場合は、YOVへジャンプ
+ JUMP SL ; ループ終端
+YOV LD GR2,TMP ; GR2の値をTMPから復元
+ SRL GR4,1 ; GR4を1回右シフト
+ JUMP LPIN ; LPINへジャンプ
+LOOP SRL GR4,1 ; ループ先頭。GR4を1回右シフト
+ JZE SETMOD ; (GR4 = 0)の場合、SETMODへループ脱出
SRL GR2,1 ; GR2を1回右シフト
- CPL GR1,ODY ; (GR1 < ODY)の場合、ループ脱出
- JMI ODFIN ; ↓
+ CPL GR1,Y ; (GR1 < Y)の場合、SETMODへループ脱出
+ JMI SETMOD ; ↓
CPL GR1,GR2 ; (GR1 < GR2)の場合、ループ先頭へジャンプ
- JMI ODLOOP ; ↓
-ODLPIN SUBL GR1,GR2 ; GR1 <- GR1 - GR2
+ JMI LOOP ; ↓
+LPIN SUBL GR1,GR2 ; GR1 <- GR1 - GR2
ADDL GR0,GR4 ; GR0 <- GR0 + GR4
- JUMP ODLOOP ; ループ終端
-ODFIN LD GR3,GR1
- POP GR4
+ JUMP LOOP ; ループ終端
+DIVZERO LAD GR3,#8000 ; 強制的にオーバーフローを発生させ、GR3 <- 0
+ SLL GR3,1 ; ↓
+ JUMP FIN ; FIN へジャンプ
+SETMOD LD GR3,GR1
+FIN POP GR4
POP GR2
POP GR1
RET
-ODY DS 1
+Y DS 1
+TMP DS 1
END
;; アドレスがGR1、長さがGR2の文字列を逆順に並べ替える
;; 例: 12345 -> 54321、54321- -> -12345
REV START
RPUSH
LAD GR3,0 ; GR3の初期化
-RPU CPL GR3,GR2 ; ループ先頭。(GR3 = GR2)の場合、ループ脱出
- JZE RNEXT ; ↓
+PU CPL GR3,GR2 ; ループ先頭。(GR3 = GR2)の場合、ループ脱出
+ JZE NEXT ; ↓
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 ; ↓
+ JUMP PU ; ループ終端
+NEXT LAD GR3,0 ; GR3の初期化
+PO CPL GR3,GR2 ; ループ先頭。(GR3 = GR2)の場合、ループ脱出
+ JZE FIN ; ↓
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
+ JUMP PO ; ループ終端
+FIN RPOP
RET
END
--- /dev/null
+;;; GR1に格納された値を、10進数の整数値(0〜65535)として表示
+OUTL START
+ RPUSH
+ LAD GR2,10 ; GR2に10進数の「10」を格納。
+ LAD GR0,0 ; GR0 <- 0
+ XOR GR4,GR4 ; 整数値の長さ
+ AND GR1,GR1 ; GR1をテスト
+ JZE ZERO ; GR1が0の場合、ZEROにジャンプ
+STI CPL GR1,GR2 ; ループ先頭。(GR1 < GR2)の場合は、ループ脱出
+ JMI STLST ; ↓
+ CALL DIVL ; GR1とGR2の、商をGR0、剰余をGR3に格納
+ LD GR1,GR3 ; GR1にGR3をコピー
+ LD GR1,NCHAR,GR1 ; GR1を文字に変換
+ ST GR1,STR,GR4 ; (STR + GR4) <- GR1
+ LAD GR4,1,GR4 ; GR4 <- GR4 + 1
+ LD GR1,GR0 ; GR0をGR1にコピー
+ JUMP STI ; ループ終端
+STLST LD GR1,NCHAR,GR1 ; GR1を文字に変換
+ ST GR1,STR,GR4 ; (STR + GR4) <- GR1
+ LAD GR4,1,GR4 ; GR4 <- GR4 + 1
+ JUMP PRT ; PRTにジャンプ
+ZERO LD GR1,NCHAR ; 「0」をSTR領域に格納
+ ST GR1,STR,GR4 ; ↓ (STR + GR4) <- GR1
+ LAD GR4,1,GR4 ; ↓ GR4 <- GR4 + 1
+PRT ST GR4,LEN ; LEN <- GR4
+ 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、長さがGR2の文字列を逆順に並べ替える
-;; 例: 12345 => 54321、54321- => -12345
+;; 例: 12345 -> 54321、54321- -> -12345
REV START
RPUSH
LAD GR3,0 ; GR3の初期化
-RPU CPL GR3,GR2 ; ループ開始。(GR3 = GR2)の場合、ループ脱出
- JZE RNEXT ; ↓
+PU CPL GR3,GR2 ; ループ先頭。(GR3 = GR2)の場合、ループ脱出
+ JZE NEXT ; ↓
LD GR4,GR1 ; GR4にGR1の値をコピー
- ADDL GR4,GR3 ; GR4 <= GR4 + GR3
+ 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 ; ↓
+ LAD GR3,1,GR3 ; GR3 <- GR3 + 1
+ JUMP PU ; ループ終端
+NEXT LAD GR3,0 ; GR3の初期化
+PO CPL GR3,GR2 ; ループ先頭。(GR3 = GR2)の場合、ループ脱出
+ JZE FIN ; ↓
POP GR5 ; GR5にポップ
LD GR4,GR1 ; GR4にGR1の値をコピー
- ADDL GR4,GR3 ; GR4 <= GR4 + GR3
+ ADDL GR4,GR3 ; GR4 <- GR4 + GR3
ST GR5,0,GR4 ; アドレスGR4にGR5の値を格納
- LAD GR3,1,GR3 ; GR3 <= GR3 + 1
- JUMP RPO ; ループ終了
-RFIN RPOP
+ LAD GR3,1,GR3 ; GR3 <- GR3 + 1
+ JUMP PO ; ループ終端
+FIN RPOP
RET
END
-../../../../casl2 -sla ../../../../as/FUNC/abs_call.casl ../../../../as/FUNC/abs.casl ../../../../as/FUNC/outa.casl
-
-Assemble ../../../../as/FUNC/abs_call.casl (0)
-../../../../as/FUNC/abs_call.casl: 1:;;; ABSを呼び出す
-../../../../as/FUNC/abs_call.casl: 2:;;; casl2 abs_call.casl abs.casl outa.casl
-../../../../as/FUNC/abs_call.casl: 3:MAIN START
-../../../../as/FUNC/abs_call.casl: 4: LAD GR2,0
-../../../../as/FUNC/abs_call.casl: 5:MLOOP CPA GR2,MLEN
-../../../../as/FUNC/abs_call.casl: 6: JZE MFIN
-../../../../as/FUNC/abs_call.casl: 7: LD GR1,MVAL,GR2
-../../../../as/FUNC/abs_call.casl: 8: CALL ABS
-../../../../as/FUNC/abs_call.casl: 9: CALL OUTA
-../../../../as/FUNC/abs_call.casl: 10: LAD GR2,1,GR2
-../../../../as/FUNC/abs_call.casl: 11: JUMP MLOOP
-../../../../as/FUNC/abs_call.casl: 12:MFIN RET
-../../../../as/FUNC/abs_call.casl: 13:MVAL DC 12,-12,1,-1,32767,-32767,0,-32768
-../../../../as/FUNC/abs_call.casl: 14:MLEN DC 8
-../../../../as/FUNC/abs_call.casl: 15: END
-
-Assemble ../../../../as/FUNC/abs.casl (0)
-../../../../as/FUNC/abs.casl: 1:;;; GR1を絶対値に変換する
-../../../../as/FUNC/abs.casl: 2:ABS START
-../../../../as/FUNC/abs.casl: 3: AND GR1,GR1
-../../../../as/FUNC/abs.casl: 4: JPL ABSFIN
-../../../../as/FUNC/abs.casl: 5: JZE ABSFIN
-../../../../as/FUNC/abs.casl: 6: XOR GR1,=#FFFF
-../../../../as/FUNC/abs.casl: 7: LAD GR1,1,GR1
-../../../../as/FUNC/abs.casl: 8:ABSFIN RET
-../../../../as/FUNC/abs.casl: 9: END
-
-Assemble ../../../../as/FUNC/outa.casl (0)
-../../../../as/FUNC/outa.casl: 1:;;; GR1に格納された値を、10進数の整数値(-32768〜32767)として表示
-../../../../as/FUNC/outa.casl: 2:OUTA START
-../../../../as/FUNC/outa.casl: 3: RPUSH
-../../../../as/FUNC/outa.casl: 4: LAD GR2,10 ; GR2に10進数の「10」を格納。
-../../../../as/FUNC/outa.casl: 5: LAD GR0,0 ; GR0 <- 0
-../../../../as/FUNC/outa.casl: 6: LAD GR4,0 ; 負数フラグ。GR1が負数の場合、GR4は1
-../../../../as/FUNC/outa.casl: 7: LAD GR5,0 ; 整数値の長さ
-../../../../as/FUNC/outa.casl: 8: AND GR1,GR1 ; GR1をテスト
-../../../../as/FUNC/outa.casl: 9: JZE ZPRT ; GR1が0の場合、ZPRTにジャンプ
-../../../../as/FUNC/outa.casl: 10: JPL STI ; GR1が正数の場合、STIにジャンプ
-../../../../as/FUNC/outa.casl: 11: LAD GR4,1 ; GR1が負数の場合、GR4をオン
-../../../../as/FUNC/outa.casl: 12: CALL OABS ; GR1を正数に変換
-../../../../as/FUNC/outa.casl: 13:STI CPL GR1,GR2 ; ループ先頭。(GR1 < GR2)の場合は、ループ脱出
-../../../../as/FUNC/outa.casl: 14: JMI STLST ; ↓
-../../../../as/FUNC/outa.casl: 15: CALL ODIVL ; GR1とGR2の、商をGR0、剰余をGR3に格納
-../../../../as/FUNC/outa.casl: 16: LD GR1,GR3 ; GR1にGR3をコピー
-../../../../as/FUNC/outa.casl: 17: LD GR1,NCHAR,GR1 ; GR1を文字に変換
-../../../../as/FUNC/outa.casl: 18: ST GR1,STR,GR5 ; (STR + GR5) <- GR1
-../../../../as/FUNC/outa.casl: 19: LAD GR5,1,GR5 ; GR5 <- GR5 + 1
-../../../../as/FUNC/outa.casl: 20: LD GR1,GR0 ; GR0をGR1にコピー
-../../../../as/FUNC/outa.casl: 21: JUMP STI ; ループ終端
-../../../../as/FUNC/outa.casl: 22:STLST LD GR1,NCHAR,GR1 ; GR1を文字に変換
-../../../../as/FUNC/outa.casl: 23: ST GR1,STR,GR5 ; (STR + GR5) <- GR1
-../../../../as/FUNC/outa.casl: 24: LAD GR5,1,GR5 ; GR5 <- GR5 + 1
-../../../../as/FUNC/outa.casl: 25: AND GR4,GR4 ; 正数の場合
-../../../../as/FUNC/outa.casl: 26: JZE PRT ; ↓
-../../../../as/FUNC/outa.casl: 27: LD GR1,='-' ; 負数の場合、「-」をSTR領域に格納
-../../../../as/FUNC/outa.casl: 28: ST GR1,STR,GR5 ; (STR + GR5) <- GR1
-../../../../as/FUNC/outa.casl: 29: LAD GR5,1,GR5 ; GR5 <- GR5 + 1
-../../../../as/FUNC/outa.casl: 30: JUMP PRT ; PRTにジャンプ
-../../../../as/FUNC/outa.casl: 31:ZPRT LD GR1,NCHAR ; 「0」をSTR領域に格納
-../../../../as/FUNC/outa.casl: 32: ST GR1,STR,GR5 ; (STR + GR5) <- GR1
-../../../../as/FUNC/outa.casl: 33: LAD GR5,1,GR5 ; GR5 <- GR5 + 1
-../../../../as/FUNC/outa.casl: 34:PRT ST GR5,LEN ; LEN <- GR5
-../../../../as/FUNC/outa.casl: 35: LD GR2,LEN ; GR2にLENの値を格納
-../../../../as/FUNC/outa.casl: 36: LAD GR1,STR ; GR1に文字列のアドレスを格納
-../../../../as/FUNC/outa.casl: 37: CALL REV ; 文字列を逆順に並べ替え
-../../../../as/FUNC/outa.casl: 38: OUT STR,LEN ; 文字列を出力
-../../../../as/FUNC/outa.casl: 39: RPOP
-../../../../as/FUNC/outa.casl: 40: RET
-../../../../as/FUNC/outa.casl: 41:STR DS 17
-../../../../as/FUNC/outa.casl: 42:LEN DS 1
-../../../../as/FUNC/outa.casl: 43:NCHAR DC '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-../../../../as/FUNC/outa.casl: 44: END
-../../../../as/FUNC/outa.casl: 45:;;; GR1の値とGR2の値の、商をGR0、剰余をGR3に格納する
-../../../../as/FUNC/outa.casl: 46:;;; 0〜65535の範囲の数値を扱う
-../../../../as/FUNC/outa.casl: 47:ODIVL START
-../../../../as/FUNC/outa.casl: 48: PUSH 0,GR1
-../../../../as/FUNC/outa.casl: 49: PUSH 0,GR2
-../../../../as/FUNC/outa.casl: 50: PUSH 0,GR4
-../../../../as/FUNC/outa.casl: 51: AND GR2,GR2 ; GR2が0の場合、ODFINへジャンプ
-../../../../as/FUNC/outa.casl: 52: JZE ODFIN ; ↓
-../../../../as/FUNC/outa.casl: 53: ST GR2,ODY ; ODYにGR2の初期値を保存
-../../../../as/FUNC/outa.casl: 54: LAD GR0,0 ; GR0の初期化
-../../../../as/FUNC/outa.casl: 55: LAD GR3,0 ; GR3の初期化
-../../../../as/FUNC/outa.casl: 56: LAD GR4,1 ; GR4の初期化。対象ビットを表す
-../../../../as/FUNC/outa.casl: 57:ODSL CPL GR2,GR1 ; ループ先頭。(GR2 > GR1)の場合、ODLOOPへループ脱出
-../../../../as/FUNC/outa.casl: 58: JPL ODLOOP ; ↓
-../../../../as/FUNC/outa.casl: 59: SLL GR4,1 ; GR4を1回左シフト
-../../../../as/FUNC/outa.casl: 60: SLL GR2,1 ; GR2を1回左シフト
-../../../../as/FUNC/outa.casl: 61: JOV ODYOV ; オーバーフローの場合は、ODYOVにジャンプ
-../../../../as/FUNC/outa.casl: 62: JUMP ODSL ; ループ終端
-../../../../as/FUNC/outa.casl: 63:ODYOV SRL GR2,1
-../../../../as/FUNC/outa.casl: 64: LAD GR2,#8000,GR2
-../../../../as/FUNC/outa.casl: 65: SRL GR4,1
-../../../../as/FUNC/outa.casl: 66: JUMP ODLPIN
-../../../../as/FUNC/outa.casl: 67:ODLOOP SRL GR4,1 ; ループ先頭。GR4を1回右シフト
-../../../../as/FUNC/outa.casl: 68: JZE ODFIN ; (GR4 = 0)の場合、ループ脱出
-../../../../as/FUNC/outa.casl: 69: SRL GR2,1 ; GR2を1回右シフト
-../../../../as/FUNC/outa.casl: 70: CPL GR1,ODY ; (GR1 < ODY)の場合、ループ脱出
-../../../../as/FUNC/outa.casl: 71: JMI ODFIN ; ↓
-../../../../as/FUNC/outa.casl: 72: CPL GR1,GR2 ; (GR1 < GR2)の場合、ループ先頭へジャンプ
-../../../../as/FUNC/outa.casl: 73: JMI ODLOOP ; ↓
-../../../../as/FUNC/outa.casl: 74:ODLPIN SUBL GR1,GR2 ; GR1 <- GR1 - GR2
-../../../../as/FUNC/outa.casl: 75: ADDL GR0,GR4 ; GR0 <- GR0 + GR4
-../../../../as/FUNC/outa.casl: 76: JUMP ODLOOP ; ループ終端
-../../../../as/FUNC/outa.casl: 77:ODFIN LD GR3,GR1
-../../../../as/FUNC/outa.casl: 78: POP GR4
-../../../../as/FUNC/outa.casl: 79: POP GR2
-../../../../as/FUNC/outa.casl: 80: POP GR1
-../../../../as/FUNC/outa.casl: 81: RET
-../../../../as/FUNC/outa.casl: 82:ODY DS 1
-../../../../as/FUNC/outa.casl: 83: END
-../../../../as/FUNC/outa.casl: 84:;; アドレスがGR1、長さがGR2の文字列を逆順に並べ替える
-../../../../as/FUNC/outa.casl: 85:;; 例: 12345 -> 54321、54321- -> -12345
-../../../../as/FUNC/outa.casl: 86:REV START
-../../../../as/FUNC/outa.casl: 87: RPUSH
-../../../../as/FUNC/outa.casl: 88: LAD GR3,0 ; GR3の初期化
-../../../../as/FUNC/outa.casl: 89:RPU CPL GR3,GR2 ; ループ先頭。(GR3 = GR2)の場合、ループ脱出
-../../../../as/FUNC/outa.casl: 90: JZE RNEXT ; ↓
-../../../../as/FUNC/outa.casl: 91: LD GR4,GR1 ; GR4にGR1の値をコピー
-../../../../as/FUNC/outa.casl: 92: ADDL GR4,GR3 ; GR4 <- GR4 + GR3
-../../../../as/FUNC/outa.casl: 93: LD GR5,0,GR4 ; GR5にアドレスGR4の値を格納
-../../../../as/FUNC/outa.casl: 94: PUSH 0,GR5 ; GR5をプッシュ
-../../../../as/FUNC/outa.casl: 95: LAD GR3,1,GR3 ; GR3 <- GR3 + 1
-../../../../as/FUNC/outa.casl: 96: JUMP RPU ; ループ終端
-../../../../as/FUNC/outa.casl: 97:RNEXT LAD GR3,0 ; GR3の初期化
-../../../../as/FUNC/outa.casl: 98:RPO CPL GR3,GR2 ; ループ先頭。(GR3 = GR2)の場合、ループ脱出
-../../../../as/FUNC/outa.casl: 99: JZE RFIN ; ↓
-../../../../as/FUNC/outa.casl: 100: POP GR5 ; GR5にポップ
-../../../../as/FUNC/outa.casl: 101: LD GR4,GR1 ; GR4にGR1の値をコピー
-../../../../as/FUNC/outa.casl: 102: ADDL GR4,GR3 ; GR4 <- GR4 + GR3
-../../../../as/FUNC/outa.casl: 103: ST GR5,0,GR4 ; アドレスGR4にGR5の値を格納
-../../../../as/FUNC/outa.casl: 104: LAD GR3,1,GR3 ; GR3 <- GR3 + 1
-../../../../as/FUNC/outa.casl: 105: JUMP RPO ; ループ終端
-../../../../as/FUNC/outa.casl: 106:RFIN RPOP
-../../../../as/FUNC/outa.casl: 107: RET
-../../../../as/FUNC/outa.casl: 108: END
-../../../../as/FUNC/outa.casl: 109:;; GR1の値を絶対値に変換する。GR1にはマイナスの数値が格納されていると想定。
-../../../../as/FUNC/outa.casl: 110:;; 例: -10 -> 10, -20 -> 20
-../../../../as/FUNC/outa.casl: 111:OABS START
-../../../../as/FUNC/outa.casl: 112: XOR GR1,=#FFFF ; GR1の値を反転
-../../../../as/FUNC/outa.casl: 113: LAD GR1,1,GR1 ; GR1 <- GR1 + 1
-../../../../as/FUNC/outa.casl: 114: RET
-../../../../as/FUNC/outa.casl: 115: END
-
-Label::::
-ODIVL.ODY ---> #00FB
-ABS.ABSFIN ---> #0023
-OUTA.LEN ---> #009C
-ODIVL.ODLOOP ---> #00E5
-ODIVL.ODLPIN ---> #00F2
-OUTA.ZPRT ---> #0063
-ABS ---> #001A
-OUTA.STI ---> #0043
-MAIN.MLOOP ---> #0002
-REV.RFIN ---> #0127
-OUTA.STR ---> #008B
-ODIVL.ODFIN ---> #00F6
-REV.RPO ---> #011B
-REV.RPU ---> #010C
-ODIVL.ODYOV ---> #00DD
-REV ---> #00FC
-REV.RNEXT ---> #0119
-OABS ---> #012F
-OUTA.NCHAR ---> #009D
-MAIN.MFIN ---> #0010
-ODIVL.ODSL ---> #00D2
-OUTA.STLST ---> #0052
-MAIN ---> #0000
-MAIN.MLEN ---> #0019
-ODIVL ---> #00C1
-MAIN.MVAL ---> #0011
-OUTA ---> #0024
-OUTA.PRT ---> #0069
-
-Assemble ../../../../as/FUNC/abs_call.casl (1)
-../../../../as/FUNC/abs_call.casl: 1:;;; ABSを呼び出す
-../../../../as/FUNC/abs_call.casl: 2:;;; casl2 abs_call.casl abs.casl outa.casl
-../../../../as/FUNC/abs_call.casl: 3:MAIN START
-../../../../as/FUNC/abs_call.casl: 4: LAD GR2,0
- #0000 #1220
- #0001 #0000
-../../../../as/FUNC/abs_call.casl: 5:MLOOP CPA GR2,MLEN
- #0002 #4020
- #0003 #0019
-../../../../as/FUNC/abs_call.casl: 6: JZE MFIN
- #0004 #6300
- #0005 #0010
-../../../../as/FUNC/abs_call.casl: 7: LD GR1,MVAL,GR2
- #0006 #1012
- #0007 #0011
-../../../../as/FUNC/abs_call.casl: 8: CALL ABS
- #0008 #8000
- #0009 #001A
-../../../../as/FUNC/abs_call.casl: 9: CALL OUTA
- #000A #8000
- #000B #0024
-../../../../as/FUNC/abs_call.casl: 10: LAD GR2,1,GR2
- #000C #1222
- #000D #0001
-../../../../as/FUNC/abs_call.casl: 11: JUMP MLOOP
- #000E #6400
- #000F #0002
-../../../../as/FUNC/abs_call.casl: 12:MFIN RET
- #0010 #8100
-../../../../as/FUNC/abs_call.casl: 13:MVAL DC 12,-12,1,-1,32767,-32767,0,-32768
- #0011 #000C
- #0012 #FFF4
- #0013 #0001
- #0014 #FFFF
- #0015 #7FFF
- #0016 #8001
- #0017 #0000
- #0018 #8000
-../../../../as/FUNC/abs_call.casl: 14:MLEN DC 8
- #0019 #0008
-../../../../as/FUNC/abs_call.casl: 15: END
-
-Assemble ../../../../as/FUNC/abs.casl (1)
-../../../../as/FUNC/abs.casl: 1:;;; GR1を絶対値に変換する
-../../../../as/FUNC/abs.casl: 2:ABS START
-../../../../as/FUNC/abs.casl: 3: AND GR1,GR1
- #001A #3411
-../../../../as/FUNC/abs.casl: 4: JPL ABSFIN
- #001B #6500
- #001C #0023
-../../../../as/FUNC/abs.casl: 5: JZE ABSFIN
- #001D #6300
- #001E #0023
-../../../../as/FUNC/abs.casl: 6: XOR GR1,=#FFFF
- #0134 #FFFF
- #001F #3210
- #0020 #0134
-../../../../as/FUNC/abs.casl: 7: LAD GR1,1,GR1
- #0021 #1211
- #0022 #0001
-../../../../as/FUNC/abs.casl: 8:ABSFIN RET
- #0023 #8100
-../../../../as/FUNC/abs.casl: 9: END
-
-Assemble ../../../../as/FUNC/outa.casl (1)
-../../../../as/FUNC/outa.casl: 1:;;; GR1に格納された値を、10進数の整数値(-32768〜32767)として表示
-../../../../as/FUNC/outa.casl: 2:OUTA START
-../../../../as/FUNC/outa.casl: 3: RPUSH
- #0024 #7001
- #0025 #0000
- #0026 #7002
- #0027 #0000
- #0028 #7003
- #0029 #0000
- #002A #7004
- #002B #0000
- #002C #7005
- #002D #0000
- #002E #7006
- #002F #0000
- #0030 #7007
- #0031 #0000
-../../../../as/FUNC/outa.casl: 4: LAD GR2,10 ; GR2に10進数の「10」を格納。
- #0032 #1220
- #0033 #000A
-../../../../as/FUNC/outa.casl: 5: LAD GR0,0 ; GR0 <- 0
- #0034 #1200
- #0035 #0000
-../../../../as/FUNC/outa.casl: 6: LAD GR4,0 ; 負数フラグ。GR1が負数の場合、GR4は1
- #0036 #1240
- #0037 #0000
-../../../../as/FUNC/outa.casl: 7: LAD GR5,0 ; 整数値の長さ
- #0038 #1250
- #0039 #0000
-../../../../as/FUNC/outa.casl: 8: AND GR1,GR1 ; GR1をテスト
- #003A #3411
-../../../../as/FUNC/outa.casl: 9: JZE ZPRT ; GR1が0の場合、ZPRTにジャンプ
- #003B #6300
- #003C #0063
-../../../../as/FUNC/outa.casl: 10: JPL STI ; GR1が正数の場合、STIにジャンプ
- #003D #6500
- #003E #0043
-../../../../as/FUNC/outa.casl: 11: LAD GR4,1 ; GR1が負数の場合、GR4をオン
- #003F #1240
- #0040 #0001
-../../../../as/FUNC/outa.casl: 12: CALL OABS ; GR1を正数に変換
- #0041 #8000
- #0042 #012F
-../../../../as/FUNC/outa.casl: 13:STI CPL GR1,GR2 ; ループ先頭。(GR1 < GR2)の場合は、ループ脱出
- #0043 #4512
-../../../../as/FUNC/outa.casl: 14: JMI STLST ; ↓
- #0044 #6100
- #0045 #0052
-../../../../as/FUNC/outa.casl: 15: CALL ODIVL ; GR1とGR2の、商をGR0、剰余をGR3に格納
- #0046 #8000
- #0047 #00C1
-../../../../as/FUNC/outa.casl: 16: LD GR1,GR3 ; GR1にGR3をコピー
- #0048 #1413
-../../../../as/FUNC/outa.casl: 17: LD GR1,NCHAR,GR1 ; GR1を文字に変換
- #0049 #1011
- #004A #009D
-../../../../as/FUNC/outa.casl: 18: ST GR1,STR,GR5 ; (STR + GR5) <- GR1
- #004B #1115
- #004C #008B
-../../../../as/FUNC/outa.casl: 19: LAD GR5,1,GR5 ; GR5 <- GR5 + 1
- #004D #1255
- #004E #0001
-../../../../as/FUNC/outa.casl: 20: LD GR1,GR0 ; GR0をGR1にコピー
- #004F #1410
-../../../../as/FUNC/outa.casl: 21: JUMP STI ; ループ終端
- #0050 #6400
- #0051 #0043
-../../../../as/FUNC/outa.casl: 22:STLST LD GR1,NCHAR,GR1 ; GR1を文字に変換
- #0052 #1011
- #0053 #009D
-../../../../as/FUNC/outa.casl: 23: ST GR1,STR,GR5 ; (STR + GR5) <- GR1
- #0054 #1115
- #0055 #008B
-../../../../as/FUNC/outa.casl: 24: LAD GR5,1,GR5 ; GR5 <- GR5 + 1
- #0056 #1255
- #0057 #0001
-../../../../as/FUNC/outa.casl: 25: AND GR4,GR4 ; 正数の場合
- #0058 #3444
-../../../../as/FUNC/outa.casl: 26: JZE PRT ; ↓
- #0059 #6300
- #005A #0069
-../../../../as/FUNC/outa.casl: 27: LD GR1,='-' ; 負数の場合、「-」をSTR領域に格納
- #0135 #002D
- #005B #1010
- #005C #0135
-../../../../as/FUNC/outa.casl: 28: ST GR1,STR,GR5 ; (STR + GR5) <- GR1
- #005D #1115
- #005E #008B
-../../../../as/FUNC/outa.casl: 29: LAD GR5,1,GR5 ; GR5 <- GR5 + 1
- #005F #1255
- #0060 #0001
-../../../../as/FUNC/outa.casl: 30: JUMP PRT ; PRTにジャンプ
- #0061 #6400
- #0062 #0069
-../../../../as/FUNC/outa.casl: 31:ZPRT LD GR1,NCHAR ; 「0」をSTR領域に格納
- #0063 #1010
- #0064 #009D
-../../../../as/FUNC/outa.casl: 32: ST GR1,STR,GR5 ; (STR + GR5) <- GR1
- #0065 #1115
- #0066 #008B
-../../../../as/FUNC/outa.casl: 33: LAD GR5,1,GR5 ; GR5 <- GR5 + 1
- #0067 #1255
- #0068 #0001
-../../../../as/FUNC/outa.casl: 34:PRT ST GR5,LEN ; LEN <- GR5
- #0069 #1150
- #006A #009C
-../../../../as/FUNC/outa.casl: 35: LD GR2,LEN ; GR2にLENの値を格納
- #006B #1020
- #006C #009C
-../../../../as/FUNC/outa.casl: 36: LAD GR1,STR ; GR1に文字列のアドレスを格納
- #006D #1210
- #006E #008B
-../../../../as/FUNC/outa.casl: 37: CALL REV ; 文字列を逆順に並べ替え
- #006F #8000
- #0070 #00FC
-../../../../as/FUNC/outa.casl: 38: OUT STR,LEN ; 文字列を出力
- #0071 #7001
- #0072 #0000
- #0073 #7002
- #0074 #0000
- #0075 #1210
- #0076 #008B
- #0077 #1020
- #0078 #009C
- #0079 #F000
- #007A #0002
- #007B #1210
- #007C #0136
- #0136 #000A
- #007D #1220
- #007E #0001
- #007F #F000
- #0080 #0002
- #0081 #7120
- #0082 #7110
-../../../../as/FUNC/outa.casl: 39: RPOP
- #0083 #7170
- #0084 #7160
- #0085 #7150
- #0086 #7140
- #0087 #7130
- #0088 #7120
- #0089 #7110
-../../../../as/FUNC/outa.casl: 40: RET
- #008A #8100
-../../../../as/FUNC/outa.casl: 41:STR DS 17
- #008B #0000
- #008C #0000
- #008D #0000
- #008E #0000
- #008F #0000
- #0090 #0000
- #0091 #0000
- #0092 #0000
- #0093 #0000
- #0094 #0000
- #0095 #0000
- #0096 #0000
- #0097 #0000
- #0098 #0000
- #0099 #0000
- #009A #0000
- #009B #0000
-../../../../as/FUNC/outa.casl: 42:LEN DS 1
- #009C #0000
-../../../../as/FUNC/outa.casl: 43:NCHAR DC '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
- #009D #0030
- #009E #0031
- #009F #0032
- #00A0 #0033
- #00A1 #0034
- #00A2 #0035
- #00A3 #0036
- #00A4 #0037
- #00A5 #0038
- #00A6 #0039
- #00A7 #0041
- #00A8 #0042
- #00A9 #0043
- #00AA #0044
- #00AB #0045
- #00AC #0046
- #00AD #0047
- #00AE #0048
- #00AF #0049
- #00B0 #004A
- #00B1 #004B
- #00B2 #004C
- #00B3 #004D
- #00B4 #004E
- #00B5 #004F
- #00B6 #0050
- #00B7 #0051
- #00B8 #0052
- #00B9 #0053
- #00BA #0054
- #00BB #0055
- #00BC #0056
- #00BD #0057
- #00BE #0058
- #00BF #0059
- #00C0 #005A
-../../../../as/FUNC/outa.casl: 44: END
-../../../../as/FUNC/outa.casl: 45:;;; GR1の値とGR2の値の、商をGR0、剰余をGR3に格納する
-../../../../as/FUNC/outa.casl: 46:;;; 0〜65535の範囲の数値を扱う
-../../../../as/FUNC/outa.casl: 47:ODIVL START
-../../../../as/FUNC/outa.casl: 48: PUSH 0,GR1
- #00C1 #7001
- #00C2 #0000
-../../../../as/FUNC/outa.casl: 49: PUSH 0,GR2
- #00C3 #7002
- #00C4 #0000
-../../../../as/FUNC/outa.casl: 50: PUSH 0,GR4
- #00C5 #7004
- #00C6 #0000
-../../../../as/FUNC/outa.casl: 51: AND GR2,GR2 ; GR2が0の場合、ODFINへジャンプ
- #00C7 #3422
-../../../../as/FUNC/outa.casl: 52: JZE ODFIN ; ↓
- #00C8 #6300
- #00C9 #00F6
-../../../../as/FUNC/outa.casl: 53: ST GR2,ODY ; ODYにGR2の初期値を保存
- #00CA #1120
- #00CB #00FB
-../../../../as/FUNC/outa.casl: 54: LAD GR0,0 ; GR0の初期化
- #00CC #1200
- #00CD #0000
-../../../../as/FUNC/outa.casl: 55: LAD GR3,0 ; GR3の初期化
- #00CE #1230
- #00CF #0000
-../../../../as/FUNC/outa.casl: 56: LAD GR4,1 ; GR4の初期化。対象ビットを表す
- #00D0 #1240
- #00D1 #0001
-../../../../as/FUNC/outa.casl: 57:ODSL CPL GR2,GR1 ; ループ先頭。(GR2 > GR1)の場合、ODLOOPへループ脱出
- #00D2 #4521
-../../../../as/FUNC/outa.casl: 58: JPL ODLOOP ; ↓
- #00D3 #6500
- #00D4 #00E5
-../../../../as/FUNC/outa.casl: 59: SLL GR4,1 ; GR4を1回左シフト
- #00D5 #5240
- #00D6 #0001
-../../../../as/FUNC/outa.casl: 60: SLL GR2,1 ; GR2を1回左シフト
- #00D7 #5220
- #00D8 #0001
-../../../../as/FUNC/outa.casl: 61: JOV ODYOV ; オーバーフローの場合は、ODYOVにジャンプ
- #00D9 #6600
- #00DA #00DD
-../../../../as/FUNC/outa.casl: 62: JUMP ODSL ; ループ終端
- #00DB #6400
- #00DC #00D2
-../../../../as/FUNC/outa.casl: 63:ODYOV SRL GR2,1
- #00DD #5320
- #00DE #0001
-../../../../as/FUNC/outa.casl: 64: LAD GR2,#8000,GR2
- #00DF #1222
- #00E0 #8000
-../../../../as/FUNC/outa.casl: 65: SRL GR4,1
- #00E1 #5340
- #00E2 #0001
-../../../../as/FUNC/outa.casl: 66: JUMP ODLPIN
- #00E3 #6400
- #00E4 #00F2
-../../../../as/FUNC/outa.casl: 67:ODLOOP SRL GR4,1 ; ループ先頭。GR4を1回右シフト
- #00E5 #5340
- #00E6 #0001
-../../../../as/FUNC/outa.casl: 68: JZE ODFIN ; (GR4 = 0)の場合、ループ脱出
- #00E7 #6300
- #00E8 #00F6
-../../../../as/FUNC/outa.casl: 69: SRL GR2,1 ; GR2を1回右シフト
- #00E9 #5320
- #00EA #0001
-../../../../as/FUNC/outa.casl: 70: CPL GR1,ODY ; (GR1 < ODY)の場合、ループ脱出
- #00EB #4110
- #00EC #00FB
-../../../../as/FUNC/outa.casl: 71: JMI ODFIN ; ↓
- #00ED #6100
- #00EE #00F6
-../../../../as/FUNC/outa.casl: 72: CPL GR1,GR2 ; (GR1 < GR2)の場合、ループ先頭へジャンプ
- #00EF #4512
-../../../../as/FUNC/outa.casl: 73: JMI ODLOOP ; ↓
- #00F0 #6100
- #00F1 #00E5
-../../../../as/FUNC/outa.casl: 74:ODLPIN SUBL GR1,GR2 ; GR1 <- GR1 - GR2
- #00F2 #2712
-../../../../as/FUNC/outa.casl: 75: ADDL GR0,GR4 ; GR0 <- GR0 + GR4
- #00F3 #2604
-../../../../as/FUNC/outa.casl: 76: JUMP ODLOOP ; ループ終端
- #00F4 #6400
- #00F5 #00E5
-../../../../as/FUNC/outa.casl: 77:ODFIN LD GR3,GR1
- #00F6 #1431
-../../../../as/FUNC/outa.casl: 78: POP GR4
- #00F7 #7140
-../../../../as/FUNC/outa.casl: 79: POP GR2
- #00F8 #7120
-../../../../as/FUNC/outa.casl: 80: POP GR1
- #00F9 #7110
-../../../../as/FUNC/outa.casl: 81: RET
- #00FA #8100
-../../../../as/FUNC/outa.casl: 82:ODY DS 1
- #00FB #0000
-../../../../as/FUNC/outa.casl: 83: END
-../../../../as/FUNC/outa.casl: 84:;; アドレスがGR1、長さがGR2の文字列を逆順に並べ替える
-../../../../as/FUNC/outa.casl: 85:;; 例: 12345 -> 54321、54321- -> -12345
-../../../../as/FUNC/outa.casl: 86:REV START
-../../../../as/FUNC/outa.casl: 87: RPUSH
- #00FC #7001
- #00FD #0000
- #00FE #7002
- #00FF #0000
- #0100 #7003
- #0101 #0000
- #0102 #7004
- #0103 #0000
- #0104 #7005
- #0105 #0000
- #0106 #7006
- #0107 #0000
- #0108 #7007
- #0109 #0000
-../../../../as/FUNC/outa.casl: 88: LAD GR3,0 ; GR3の初期化
- #010A #1230
- #010B #0000
-../../../../as/FUNC/outa.casl: 89:RPU CPL GR3,GR2 ; ループ先頭。(GR3 = GR2)の場合、ループ脱出
- #010C #4532
-../../../../as/FUNC/outa.casl: 90: JZE RNEXT ; ↓
- #010D #6300
- #010E #0119
-../../../../as/FUNC/outa.casl: 91: LD GR4,GR1 ; GR4にGR1の値をコピー
- #010F #1441
-../../../../as/FUNC/outa.casl: 92: ADDL GR4,GR3 ; GR4 <- GR4 + GR3
- #0110 #2643
-../../../../as/FUNC/outa.casl: 93: LD GR5,0,GR4 ; GR5にアドレスGR4の値を格納
- #0111 #1054
- #0112 #0000
-../../../../as/FUNC/outa.casl: 94: PUSH 0,GR5 ; GR5をプッシュ
- #0113 #7005
- #0114 #0000
-../../../../as/FUNC/outa.casl: 95: LAD GR3,1,GR3 ; GR3 <- GR3 + 1
- #0115 #1233
- #0116 #0001
-../../../../as/FUNC/outa.casl: 96: JUMP RPU ; ループ終端
- #0117 #6400
- #0118 #010C
-../../../../as/FUNC/outa.casl: 97:RNEXT LAD GR3,0 ; GR3の初期化
- #0119 #1230
- #011A #0000
-../../../../as/FUNC/outa.casl: 98:RPO CPL GR3,GR2 ; ループ先頭。(GR3 = GR2)の場合、ループ脱出
- #011B #4532
-../../../../as/FUNC/outa.casl: 99: JZE RFIN ; ↓
- #011C #6300
- #011D #0127
-../../../../as/FUNC/outa.casl: 100: POP GR5 ; GR5にポップ
- #011E #7150
-../../../../as/FUNC/outa.casl: 101: LD GR4,GR1 ; GR4にGR1の値をコピー
- #011F #1441
-../../../../as/FUNC/outa.casl: 102: ADDL GR4,GR3 ; GR4 <- GR4 + GR3
- #0120 #2643
-../../../../as/FUNC/outa.casl: 103: ST GR5,0,GR4 ; アドレスGR4にGR5の値を格納
- #0121 #1154
- #0122 #0000
-../../../../as/FUNC/outa.casl: 104: LAD GR3,1,GR3 ; GR3 <- GR3 + 1
- #0123 #1233
- #0124 #0001
-../../../../as/FUNC/outa.casl: 105: JUMP RPO ; ループ終端
- #0125 #6400
- #0126 #011B
-../../../../as/FUNC/outa.casl: 106:RFIN RPOP
- #0127 #7170
- #0128 #7160
- #0129 #7150
- #012A #7140
- #012B #7130
- #012C #7120
- #012D #7110
-../../../../as/FUNC/outa.casl: 107: RET
- #012E #8100
-../../../../as/FUNC/outa.casl: 108: END
-../../../../as/FUNC/outa.casl: 109:;; GR1の値を絶対値に変換する。GR1にはマイナスの数値が格納されていると想定。
-../../../../as/FUNC/outa.casl: 110:;; 例: -10 -> 10, -20 -> 20
-../../../../as/FUNC/outa.casl: 111:OABS START
-../../../../as/FUNC/outa.casl: 112: XOR GR1,=#FFFF ; GR1の値を反転
- #0137 #FFFF
- #012F #3210
- #0130 #0137
-../../../../as/FUNC/outa.casl: 113: LAD GR1,1,GR1 ; GR1 <- GR1 + 1
- #0131 #1211
- #0132 #0001
-../../../../as/FUNC/outa.casl: 114: RET
- #0133 #8100
-../../../../as/FUNC/outa.casl: 115: END
+../../../../casl2 ../../../../as/FUNC/abs_call.casl ../../../../as/FUNC/abs.casl ../../../../as/FUNC/outa_main.casl ../../../../as/FUNC/divl1.casl ../../../../as/FUNC/rev.casl
12
12
1
include ../CMD.mk # YACASL2DIR, CASL2
-CASL2FLAG = -sla
ASDIR = $(YACASL2DIR)/as/FUNC
-ASFILE = $(ASDIR)/abs_call.casl $(ASDIR)/abs.casl $(ASDIR)/outa.casl
-CMD = $(CASL2) $(CASL2FLAG) $(ASFILE) $(IN)
+ASFILE = $(ASDIR)/abs_call.casl $(ASDIR)/abs.casl $(ASDIR)/outa_main.casl $(ASDIR)/divl1.casl $(ASDIR)/rev.casl
+CMD = $(CASL2) $(ASFILE)
include ../TEST.mk
-../../../../casl2 -sla ../../../../as/FUNC/count1_call.casl ../../../../as/FUNC/count1.casl ../../../../as/FUNC/outa.casl
-
-Assemble ../../../../as/FUNC/count1_call.casl (0)
-../../../../as/FUNC/count1_call.casl: 1:;; count1.casl(「アセンブラ言語の仕様」プログラム例)を呼び出し、出力結果を表示
-../../../../as/FUNC/count1_call.casl: 2:;; 使い方: casl2 count1_call.casl count1.casl outa.casl
-../../../../as/FUNC/count1_call.casl: 3:MAIN START
-../../../../as/FUNC/count1_call.casl: 4: LAD GR2,0
-../../../../as/FUNC/count1_call.casl: 5:LOOP CPA GR2,MAX ; ループ開始。GR2がMAXの値になったらループ脱出
-../../../../as/FUNC/count1_call.casl: 6: JZE FIN ; ↓
-../../../../as/FUNC/count1_call.casl: 7: LD GR1,GR2 ; GR1にVALの値をロード
-../../../../as/FUNC/count1_call.casl: 8: CALL COUNT1 ; COUNT1を呼び出す。出力はGR0に格納
-../../../../as/FUNC/count1_call.casl: 9: LD GR1,GR0 ; GR1にGR0の値をコピー
-../../../../as/FUNC/count1_call.casl: 10: CALL OUTA ; OUTAを呼び出す
-../../../../as/FUNC/count1_call.casl: 11: LAD GR2,1,GR2 ; GR2 <= GR2 + 1
-../../../../as/FUNC/count1_call.casl: 12: JUMP LOOP ; ループ終端
-../../../../as/FUNC/count1_call.casl: 13:FIN RET
-../../../../as/FUNC/count1_call.casl: 14:MAX DC 256
-../../../../as/FUNC/count1_call.casl: 15: END
-
-Assemble ../../../../as/FUNC/count1.casl (0)
-../../../../as/FUNC/count1.casl: 1:COUNT1 START
-../../../../as/FUNC/count1.casl: 2:; 入力 GR1:検索する語
-../../../../as/FUNC/count1.casl: 3:; 処理 GR1中の'1'のビットの個数を求める
-../../../../as/FUNC/count1.casl: 4:; 出力 GR0:GR1中の'1'のビットの個数
-../../../../as/FUNC/count1.casl: 5: PUSH 0,GR1
-../../../../as/FUNC/count1.casl: 6: PUSH 0,GR2
-../../../../as/FUNC/count1.casl: 7: SUBA GR2,GR2
-../../../../as/FUNC/count1.casl: 8: AND GR1,GR1
-../../../../as/FUNC/count1.casl: 9: JZE RETURN
-../../../../as/FUNC/count1.casl: 10:MORE LAD GR2,1,GR2
-../../../../as/FUNC/count1.casl: 11: LAD GR0,-1,GR1
-../../../../as/FUNC/count1.casl: 12: AND GR1,GR0
-../../../../as/FUNC/count1.casl: 13: JNZ MORE
-../../../../as/FUNC/count1.casl: 14:RETURN LD GR0,GR2
-../../../../as/FUNC/count1.casl: 15: POP GR2
-../../../../as/FUNC/count1.casl: 16: POP GR1
-../../../../as/FUNC/count1.casl: 17: RET
-../../../../as/FUNC/count1.casl: 18: END
-
-Assemble ../../../../as/FUNC/outa.casl (0)
-../../../../as/FUNC/outa.casl: 1:;;; GR1に格納された値を、10進数の整数値(-32768〜32767)として表示
-../../../../as/FUNC/outa.casl: 2:OUTA START
-../../../../as/FUNC/outa.casl: 3: RPUSH
-../../../../as/FUNC/outa.casl: 4: LAD GR2,10 ; GR2に10進数の「10」を格納。
-../../../../as/FUNC/outa.casl: 5: LAD GR0,0 ; GR0 <- 0
-../../../../as/FUNC/outa.casl: 6: LAD GR4,0 ; 負数フラグ。GR1が負数の場合、GR4は1
-../../../../as/FUNC/outa.casl: 7: LAD GR5,0 ; 整数値の長さ
-../../../../as/FUNC/outa.casl: 8: AND GR1,GR1 ; GR1をテスト
-../../../../as/FUNC/outa.casl: 9: JZE ZPRT ; GR1が0の場合、ZPRTにジャンプ
-../../../../as/FUNC/outa.casl: 10: JPL STI ; GR1が正数の場合、STIにジャンプ
-../../../../as/FUNC/outa.casl: 11: LAD GR4,1 ; GR1が負数の場合、GR4をオン
-../../../../as/FUNC/outa.casl: 12: CALL OABS ; GR1を正数に変換
-../../../../as/FUNC/outa.casl: 13:STI CPL GR1,GR2 ; ループ先頭。(GR1 < GR2)の場合は、ループ脱出
-../../../../as/FUNC/outa.casl: 14: JMI STLST ; ↓
-../../../../as/FUNC/outa.casl: 15: CALL ODIVL ; GR1とGR2の、商をGR0、剰余をGR3に格納
-../../../../as/FUNC/outa.casl: 16: LD GR1,GR3 ; GR1にGR3をコピー
-../../../../as/FUNC/outa.casl: 17: LD GR1,NCHAR,GR1 ; GR1を文字に変換
-../../../../as/FUNC/outa.casl: 18: ST GR1,STR,GR5 ; (STR + GR5) <- GR1
-../../../../as/FUNC/outa.casl: 19: LAD GR5,1,GR5 ; GR5 <- GR5 + 1
-../../../../as/FUNC/outa.casl: 20: LD GR1,GR0 ; GR0をGR1にコピー
-../../../../as/FUNC/outa.casl: 21: JUMP STI ; ループ終端
-../../../../as/FUNC/outa.casl: 22:STLST LD GR1,NCHAR,GR1 ; GR1を文字に変換
-../../../../as/FUNC/outa.casl: 23: ST GR1,STR,GR5 ; (STR + GR5) <- GR1
-../../../../as/FUNC/outa.casl: 24: LAD GR5,1,GR5 ; GR5 <- GR5 + 1
-../../../../as/FUNC/outa.casl: 25: AND GR4,GR4 ; 正数の場合
-../../../../as/FUNC/outa.casl: 26: JZE PRT ; ↓
-../../../../as/FUNC/outa.casl: 27: LD GR1,='-' ; 負数の場合、「-」をSTR領域に格納
-../../../../as/FUNC/outa.casl: 28: ST GR1,STR,GR5 ; (STR + GR5) <- GR1
-../../../../as/FUNC/outa.casl: 29: LAD GR5,1,GR5 ; GR5 <- GR5 + 1
-../../../../as/FUNC/outa.casl: 30: JUMP PRT ; PRTにジャンプ
-../../../../as/FUNC/outa.casl: 31:ZPRT LD GR1,NCHAR ; 「0」をSTR領域に格納
-../../../../as/FUNC/outa.casl: 32: ST GR1,STR,GR5 ; (STR + GR5) <- GR1
-../../../../as/FUNC/outa.casl: 33: LAD GR5,1,GR5 ; GR5 <- GR5 + 1
-../../../../as/FUNC/outa.casl: 34:PRT ST GR5,LEN ; LEN <- GR5
-../../../../as/FUNC/outa.casl: 35: LD GR2,LEN ; GR2にLENの値を格納
-../../../../as/FUNC/outa.casl: 36: LAD GR1,STR ; GR1に文字列のアドレスを格納
-../../../../as/FUNC/outa.casl: 37: CALL REV ; 文字列を逆順に並べ替え
-../../../../as/FUNC/outa.casl: 38: OUT STR,LEN ; 文字列を出力
-../../../../as/FUNC/outa.casl: 39: RPOP
-../../../../as/FUNC/outa.casl: 40: RET
-../../../../as/FUNC/outa.casl: 41:STR DS 17
-../../../../as/FUNC/outa.casl: 42:LEN DS 1
-../../../../as/FUNC/outa.casl: 43:NCHAR DC '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-../../../../as/FUNC/outa.casl: 44: END
-../../../../as/FUNC/outa.casl: 45:;;; GR1の値とGR2の値の、商をGR0、剰余をGR3に格納する
-../../../../as/FUNC/outa.casl: 46:;;; 0〜65535の範囲の数値を扱う
-../../../../as/FUNC/outa.casl: 47:ODIVL START
-../../../../as/FUNC/outa.casl: 48: PUSH 0,GR1
-../../../../as/FUNC/outa.casl: 49: PUSH 0,GR2
-../../../../as/FUNC/outa.casl: 50: PUSH 0,GR4
-../../../../as/FUNC/outa.casl: 51: AND GR2,GR2 ; GR2が0の場合、ODFINへジャンプ
-../../../../as/FUNC/outa.casl: 52: JZE ODFIN ; ↓
-../../../../as/FUNC/outa.casl: 53: ST GR2,ODY ; ODYにGR2の初期値を保存
-../../../../as/FUNC/outa.casl: 54: LAD GR0,0 ; GR0の初期化
-../../../../as/FUNC/outa.casl: 55: LAD GR3,0 ; GR3の初期化
-../../../../as/FUNC/outa.casl: 56: LAD GR4,1 ; GR4の初期化。対象ビットを表す
-../../../../as/FUNC/outa.casl: 57:ODSL CPL GR2,GR1 ; ループ先頭。(GR2 > GR1)の場合、ODLOOPへループ脱出
-../../../../as/FUNC/outa.casl: 58: JPL ODLOOP ; ↓
-../../../../as/FUNC/outa.casl: 59: SLL GR4,1 ; GR4を1回左シフト
-../../../../as/FUNC/outa.casl: 60: SLL GR2,1 ; GR2を1回左シフト
-../../../../as/FUNC/outa.casl: 61: JOV ODYOV ; オーバーフローの場合は、ODYOVにジャンプ
-../../../../as/FUNC/outa.casl: 62: JUMP ODSL ; ループ終端
-../../../../as/FUNC/outa.casl: 63:ODYOV SRL GR2,1
-../../../../as/FUNC/outa.casl: 64: LAD GR2,#8000,GR2
-../../../../as/FUNC/outa.casl: 65: SRL GR4,1
-../../../../as/FUNC/outa.casl: 66: JUMP ODLPIN
-../../../../as/FUNC/outa.casl: 67:ODLOOP SRL GR4,1 ; ループ先頭。GR4を1回右シフト
-../../../../as/FUNC/outa.casl: 68: JZE ODFIN ; (GR4 = 0)の場合、ループ脱出
-../../../../as/FUNC/outa.casl: 69: SRL GR2,1 ; GR2を1回右シフト
-../../../../as/FUNC/outa.casl: 70: CPL GR1,ODY ; (GR1 < ODY)の場合、ループ脱出
-../../../../as/FUNC/outa.casl: 71: JMI ODFIN ; ↓
-../../../../as/FUNC/outa.casl: 72: CPL GR1,GR2 ; (GR1 < GR2)の場合、ループ先頭へジャンプ
-../../../../as/FUNC/outa.casl: 73: JMI ODLOOP ; ↓
-../../../../as/FUNC/outa.casl: 74:ODLPIN SUBL GR1,GR2 ; GR1 <- GR1 - GR2
-../../../../as/FUNC/outa.casl: 75: ADDL GR0,GR4 ; GR0 <- GR0 + GR4
-../../../../as/FUNC/outa.casl: 76: JUMP ODLOOP ; ループ終端
-../../../../as/FUNC/outa.casl: 77:ODFIN LD GR3,GR1
-../../../../as/FUNC/outa.casl: 78: POP GR4
-../../../../as/FUNC/outa.casl: 79: POP GR2
-../../../../as/FUNC/outa.casl: 80: POP GR1
-../../../../as/FUNC/outa.casl: 81: RET
-../../../../as/FUNC/outa.casl: 82:ODY DS 1
-../../../../as/FUNC/outa.casl: 83: END
-../../../../as/FUNC/outa.casl: 84:;; アドレスがGR1、長さがGR2の文字列を逆順に並べ替える
-../../../../as/FUNC/outa.casl: 85:;; 例: 12345 -> 54321、54321- -> -12345
-../../../../as/FUNC/outa.casl: 86:REV START
-../../../../as/FUNC/outa.casl: 87: RPUSH
-../../../../as/FUNC/outa.casl: 88: LAD GR3,0 ; GR3の初期化
-../../../../as/FUNC/outa.casl: 89:RPU CPL GR3,GR2 ; ループ先頭。(GR3 = GR2)の場合、ループ脱出
-../../../../as/FUNC/outa.casl: 90: JZE RNEXT ; ↓
-../../../../as/FUNC/outa.casl: 91: LD GR4,GR1 ; GR4にGR1の値をコピー
-../../../../as/FUNC/outa.casl: 92: ADDL GR4,GR3 ; GR4 <- GR4 + GR3
-../../../../as/FUNC/outa.casl: 93: LD GR5,0,GR4 ; GR5にアドレスGR4の値を格納
-../../../../as/FUNC/outa.casl: 94: PUSH 0,GR5 ; GR5をプッシュ
-../../../../as/FUNC/outa.casl: 95: LAD GR3,1,GR3 ; GR3 <- GR3 + 1
-../../../../as/FUNC/outa.casl: 96: JUMP RPU ; ループ終端
-../../../../as/FUNC/outa.casl: 97:RNEXT LAD GR3,0 ; GR3の初期化
-../../../../as/FUNC/outa.casl: 98:RPO CPL GR3,GR2 ; ループ先頭。(GR3 = GR2)の場合、ループ脱出
-../../../../as/FUNC/outa.casl: 99: JZE RFIN ; ↓
-../../../../as/FUNC/outa.casl: 100: POP GR5 ; GR5にポップ
-../../../../as/FUNC/outa.casl: 101: LD GR4,GR1 ; GR4にGR1の値をコピー
-../../../../as/FUNC/outa.casl: 102: ADDL GR4,GR3 ; GR4 <- GR4 + GR3
-../../../../as/FUNC/outa.casl: 103: ST GR5,0,GR4 ; アドレスGR4にGR5の値を格納
-../../../../as/FUNC/outa.casl: 104: LAD GR3,1,GR3 ; GR3 <- GR3 + 1
-../../../../as/FUNC/outa.casl: 105: JUMP RPO ; ループ終端
-../../../../as/FUNC/outa.casl: 106:RFIN RPOP
-../../../../as/FUNC/outa.casl: 107: RET
-../../../../as/FUNC/outa.casl: 108: END
-../../../../as/FUNC/outa.casl: 109:;; GR1の値を絶対値に変換する。GR1にはマイナスの数値が格納されていると想定。
-../../../../as/FUNC/outa.casl: 110:;; 例: -10 -> 10, -20 -> 20
-../../../../as/FUNC/outa.casl: 111:OABS START
-../../../../as/FUNC/outa.casl: 112: XOR GR1,=#FFFF ; GR1の値を反転
-../../../../as/FUNC/outa.casl: 113: LAD GR1,1,GR1 ; GR1 <- GR1 + 1
-../../../../as/FUNC/outa.casl: 114: RET
-../../../../as/FUNC/outa.casl: 115: END
-
-Label::::
-ODIVL.ODY ---> #00FC
-COUNT1 ---> #0012
-OUTA.LEN ---> #009D
-ODIVL.ODLOOP ---> #00E6
-ODIVL.ODLPIN ---> #00F3
-OUTA.ZPRT ---> #0064
-OUTA.STI ---> #0044
-REV.RFIN ---> #0128
-OUTA.STR ---> #008C
-ODIVL.ODFIN ---> #00F7
-REV.RPO ---> #011C
-REV.RPU ---> #010D
-COUNT1.MORE ---> #001A
-ODIVL.ODYOV ---> #00DE
-REV ---> #00FD
-MAIN.FIN ---> #0010
-REV.RNEXT ---> #011A
-OABS ---> #0130
-OUTA.NCHAR ---> #009E
-ODIVL.ODSL ---> #00D3
-OUTA.STLST ---> #0053
-MAIN ---> #0000
-ODIVL ---> #00C2
-COUNT1.RETURN ---> #0021
-OUTA ---> #0025
-MAIN.LOOP ---> #0002
-OUTA.PRT ---> #006A
-MAIN.MAX ---> #0011
-
-Assemble ../../../../as/FUNC/count1_call.casl (1)
-../../../../as/FUNC/count1_call.casl: 1:;; count1.casl(「アセンブラ言語の仕様」プログラム例)を呼び出し、出力結果を表示
-../../../../as/FUNC/count1_call.casl: 2:;; 使い方: casl2 count1_call.casl count1.casl outa.casl
-../../../../as/FUNC/count1_call.casl: 3:MAIN START
-../../../../as/FUNC/count1_call.casl: 4: LAD GR2,0
- #0000 #1220
- #0001 #0000
-../../../../as/FUNC/count1_call.casl: 5:LOOP CPA GR2,MAX ; ループ開始。GR2がMAXの値になったらループ脱出
- #0002 #4020
- #0003 #0011
-../../../../as/FUNC/count1_call.casl: 6: JZE FIN ; ↓
- #0004 #6300
- #0005 #0010
-../../../../as/FUNC/count1_call.casl: 7: LD GR1,GR2 ; GR1にVALの値をロード
- #0006 #1412
-../../../../as/FUNC/count1_call.casl: 8: CALL COUNT1 ; COUNT1を呼び出す。出力はGR0に格納
- #0007 #8000
- #0008 #0012
-../../../../as/FUNC/count1_call.casl: 9: LD GR1,GR0 ; GR1にGR0の値をコピー
- #0009 #1410
-../../../../as/FUNC/count1_call.casl: 10: CALL OUTA ; OUTAを呼び出す
- #000A #8000
- #000B #0025
-../../../../as/FUNC/count1_call.casl: 11: LAD GR2,1,GR2 ; GR2 <= GR2 + 1
- #000C #1222
- #000D #0001
-../../../../as/FUNC/count1_call.casl: 12: JUMP LOOP ; ループ終端
- #000E #6400
- #000F #0002
-../../../../as/FUNC/count1_call.casl: 13:FIN RET
- #0010 #8100
-../../../../as/FUNC/count1_call.casl: 14:MAX DC 256
- #0011 #0100
-../../../../as/FUNC/count1_call.casl: 15: END
-
-Assemble ../../../../as/FUNC/count1.casl (1)
-../../../../as/FUNC/count1.casl: 1:COUNT1 START
-../../../../as/FUNC/count1.casl: 2:; 入力 GR1:検索する語
-../../../../as/FUNC/count1.casl: 3:; 処理 GR1中の'1'のビットの個数を求める
-../../../../as/FUNC/count1.casl: 4:; 出力 GR0:GR1中の'1'のビットの個数
-../../../../as/FUNC/count1.casl: 5: PUSH 0,GR1
- #0012 #7001
- #0013 #0000
-../../../../as/FUNC/count1.casl: 6: PUSH 0,GR2
- #0014 #7002
- #0015 #0000
-../../../../as/FUNC/count1.casl: 7: SUBA GR2,GR2
- #0016 #2522
-../../../../as/FUNC/count1.casl: 8: AND GR1,GR1
- #0017 #3411
-../../../../as/FUNC/count1.casl: 9: JZE RETURN
- #0018 #6300
- #0019 #0021
-../../../../as/FUNC/count1.casl: 10:MORE LAD GR2,1,GR2
- #001A #1222
- #001B #0001
-../../../../as/FUNC/count1.casl: 11: LAD GR0,-1,GR1
- #001C #1201
- #001D #FFFF
-../../../../as/FUNC/count1.casl: 12: AND GR1,GR0
- #001E #3410
-../../../../as/FUNC/count1.casl: 13: JNZ MORE
- #001F #6200
- #0020 #001A
-../../../../as/FUNC/count1.casl: 14:RETURN LD GR0,GR2
- #0021 #1402
-../../../../as/FUNC/count1.casl: 15: POP GR2
- #0022 #7120
-../../../../as/FUNC/count1.casl: 16: POP GR1
- #0023 #7110
-../../../../as/FUNC/count1.casl: 17: RET
- #0024 #8100
-../../../../as/FUNC/count1.casl: 18: END
-
-Assemble ../../../../as/FUNC/outa.casl (1)
-../../../../as/FUNC/outa.casl: 1:;;; GR1に格納された値を、10進数の整数値(-32768〜32767)として表示
-../../../../as/FUNC/outa.casl: 2:OUTA START
-../../../../as/FUNC/outa.casl: 3: RPUSH
- #0025 #7001
- #0026 #0000
- #0027 #7002
- #0028 #0000
- #0029 #7003
- #002A #0000
- #002B #7004
- #002C #0000
- #002D #7005
- #002E #0000
- #002F #7006
- #0030 #0000
- #0031 #7007
- #0032 #0000
-../../../../as/FUNC/outa.casl: 4: LAD GR2,10 ; GR2に10進数の「10」を格納。
- #0033 #1220
- #0034 #000A
-../../../../as/FUNC/outa.casl: 5: LAD GR0,0 ; GR0 <- 0
- #0035 #1200
- #0036 #0000
-../../../../as/FUNC/outa.casl: 6: LAD GR4,0 ; 負数フラグ。GR1が負数の場合、GR4は1
- #0037 #1240
- #0038 #0000
-../../../../as/FUNC/outa.casl: 7: LAD GR5,0 ; 整数値の長さ
- #0039 #1250
- #003A #0000
-../../../../as/FUNC/outa.casl: 8: AND GR1,GR1 ; GR1をテスト
- #003B #3411
-../../../../as/FUNC/outa.casl: 9: JZE ZPRT ; GR1が0の場合、ZPRTにジャンプ
- #003C #6300
- #003D #0064
-../../../../as/FUNC/outa.casl: 10: JPL STI ; GR1が正数の場合、STIにジャンプ
- #003E #6500
- #003F #0044
-../../../../as/FUNC/outa.casl: 11: LAD GR4,1 ; GR1が負数の場合、GR4をオン
- #0040 #1240
- #0041 #0001
-../../../../as/FUNC/outa.casl: 12: CALL OABS ; GR1を正数に変換
- #0042 #8000
- #0043 #0130
-../../../../as/FUNC/outa.casl: 13:STI CPL GR1,GR2 ; ループ先頭。(GR1 < GR2)の場合は、ループ脱出
- #0044 #4512
-../../../../as/FUNC/outa.casl: 14: JMI STLST ; ↓
- #0045 #6100
- #0046 #0053
-../../../../as/FUNC/outa.casl: 15: CALL ODIVL ; GR1とGR2の、商をGR0、剰余をGR3に格納
- #0047 #8000
- #0048 #00C2
-../../../../as/FUNC/outa.casl: 16: LD GR1,GR3 ; GR1にGR3をコピー
- #0049 #1413
-../../../../as/FUNC/outa.casl: 17: LD GR1,NCHAR,GR1 ; GR1を文字に変換
- #004A #1011
- #004B #009E
-../../../../as/FUNC/outa.casl: 18: ST GR1,STR,GR5 ; (STR + GR5) <- GR1
- #004C #1115
- #004D #008C
-../../../../as/FUNC/outa.casl: 19: LAD GR5,1,GR5 ; GR5 <- GR5 + 1
- #004E #1255
- #004F #0001
-../../../../as/FUNC/outa.casl: 20: LD GR1,GR0 ; GR0をGR1にコピー
- #0050 #1410
-../../../../as/FUNC/outa.casl: 21: JUMP STI ; ループ終端
- #0051 #6400
- #0052 #0044
-../../../../as/FUNC/outa.casl: 22:STLST LD GR1,NCHAR,GR1 ; GR1を文字に変換
- #0053 #1011
- #0054 #009E
-../../../../as/FUNC/outa.casl: 23: ST GR1,STR,GR5 ; (STR + GR5) <- GR1
- #0055 #1115
- #0056 #008C
-../../../../as/FUNC/outa.casl: 24: LAD GR5,1,GR5 ; GR5 <- GR5 + 1
- #0057 #1255
- #0058 #0001
-../../../../as/FUNC/outa.casl: 25: AND GR4,GR4 ; 正数の場合
- #0059 #3444
-../../../../as/FUNC/outa.casl: 26: JZE PRT ; ↓
- #005A #6300
- #005B #006A
-../../../../as/FUNC/outa.casl: 27: LD GR1,='-' ; 負数の場合、「-」をSTR領域に格納
- #0135 #002D
- #005C #1010
- #005D #0135
-../../../../as/FUNC/outa.casl: 28: ST GR1,STR,GR5 ; (STR + GR5) <- GR1
- #005E #1115
- #005F #008C
-../../../../as/FUNC/outa.casl: 29: LAD GR5,1,GR5 ; GR5 <- GR5 + 1
- #0060 #1255
- #0061 #0001
-../../../../as/FUNC/outa.casl: 30: JUMP PRT ; PRTにジャンプ
- #0062 #6400
- #0063 #006A
-../../../../as/FUNC/outa.casl: 31:ZPRT LD GR1,NCHAR ; 「0」をSTR領域に格納
- #0064 #1010
- #0065 #009E
-../../../../as/FUNC/outa.casl: 32: ST GR1,STR,GR5 ; (STR + GR5) <- GR1
- #0066 #1115
- #0067 #008C
-../../../../as/FUNC/outa.casl: 33: LAD GR5,1,GR5 ; GR5 <- GR5 + 1
- #0068 #1255
- #0069 #0001
-../../../../as/FUNC/outa.casl: 34:PRT ST GR5,LEN ; LEN <- GR5
- #006A #1150
- #006B #009D
-../../../../as/FUNC/outa.casl: 35: LD GR2,LEN ; GR2にLENの値を格納
- #006C #1020
- #006D #009D
-../../../../as/FUNC/outa.casl: 36: LAD GR1,STR ; GR1に文字列のアドレスを格納
- #006E #1210
- #006F #008C
-../../../../as/FUNC/outa.casl: 37: CALL REV ; 文字列を逆順に並べ替え
- #0070 #8000
- #0071 #00FD
-../../../../as/FUNC/outa.casl: 38: OUT STR,LEN ; 文字列を出力
- #0072 #7001
- #0073 #0000
- #0074 #7002
- #0075 #0000
- #0076 #1210
- #0077 #008C
- #0078 #1020
- #0079 #009D
- #007A #F000
- #007B #0002
- #007C #1210
- #007D #0136
- #0136 #000A
- #007E #1220
- #007F #0001
- #0080 #F000
- #0081 #0002
- #0082 #7120
- #0083 #7110
-../../../../as/FUNC/outa.casl: 39: RPOP
- #0084 #7170
- #0085 #7160
- #0086 #7150
- #0087 #7140
- #0088 #7130
- #0089 #7120
- #008A #7110
-../../../../as/FUNC/outa.casl: 40: RET
- #008B #8100
-../../../../as/FUNC/outa.casl: 41:STR DS 17
- #008C #0000
- #008D #0000
- #008E #0000
- #008F #0000
- #0090 #0000
- #0091 #0000
- #0092 #0000
- #0093 #0000
- #0094 #0000
- #0095 #0000
- #0096 #0000
- #0097 #0000
- #0098 #0000
- #0099 #0000
- #009A #0000
- #009B #0000
- #009C #0000
-../../../../as/FUNC/outa.casl: 42:LEN DS 1
- #009D #0000
-../../../../as/FUNC/outa.casl: 43:NCHAR DC '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
- #009E #0030
- #009F #0031
- #00A0 #0032
- #00A1 #0033
- #00A2 #0034
- #00A3 #0035
- #00A4 #0036
- #00A5 #0037
- #00A6 #0038
- #00A7 #0039
- #00A8 #0041
- #00A9 #0042
- #00AA #0043
- #00AB #0044
- #00AC #0045
- #00AD #0046
- #00AE #0047
- #00AF #0048
- #00B0 #0049
- #00B1 #004A
- #00B2 #004B
- #00B3 #004C
- #00B4 #004D
- #00B5 #004E
- #00B6 #004F
- #00B7 #0050
- #00B8 #0051
- #00B9 #0052
- #00BA #0053
- #00BB #0054
- #00BC #0055
- #00BD #0056
- #00BE #0057
- #00BF #0058
- #00C0 #0059
- #00C1 #005A
-../../../../as/FUNC/outa.casl: 44: END
-../../../../as/FUNC/outa.casl: 45:;;; GR1の値とGR2の値の、商をGR0、剰余をGR3に格納する
-../../../../as/FUNC/outa.casl: 46:;;; 0〜65535の範囲の数値を扱う
-../../../../as/FUNC/outa.casl: 47:ODIVL START
-../../../../as/FUNC/outa.casl: 48: PUSH 0,GR1
- #00C2 #7001
- #00C3 #0000
-../../../../as/FUNC/outa.casl: 49: PUSH 0,GR2
- #00C4 #7002
- #00C5 #0000
-../../../../as/FUNC/outa.casl: 50: PUSH 0,GR4
- #00C6 #7004
- #00C7 #0000
-../../../../as/FUNC/outa.casl: 51: AND GR2,GR2 ; GR2が0の場合、ODFINへジャンプ
- #00C8 #3422
-../../../../as/FUNC/outa.casl: 52: JZE ODFIN ; ↓
- #00C9 #6300
- #00CA #00F7
-../../../../as/FUNC/outa.casl: 53: ST GR2,ODY ; ODYにGR2の初期値を保存
- #00CB #1120
- #00CC #00FC
-../../../../as/FUNC/outa.casl: 54: LAD GR0,0 ; GR0の初期化
- #00CD #1200
- #00CE #0000
-../../../../as/FUNC/outa.casl: 55: LAD GR3,0 ; GR3の初期化
- #00CF #1230
- #00D0 #0000
-../../../../as/FUNC/outa.casl: 56: LAD GR4,1 ; GR4の初期化。対象ビットを表す
- #00D1 #1240
- #00D2 #0001
-../../../../as/FUNC/outa.casl: 57:ODSL CPL GR2,GR1 ; ループ先頭。(GR2 > GR1)の場合、ODLOOPへループ脱出
- #00D3 #4521
-../../../../as/FUNC/outa.casl: 58: JPL ODLOOP ; ↓
- #00D4 #6500
- #00D5 #00E6
-../../../../as/FUNC/outa.casl: 59: SLL GR4,1 ; GR4を1回左シフト
- #00D6 #5240
- #00D7 #0001
-../../../../as/FUNC/outa.casl: 60: SLL GR2,1 ; GR2を1回左シフト
- #00D8 #5220
- #00D9 #0001
-../../../../as/FUNC/outa.casl: 61: JOV ODYOV ; オーバーフローの場合は、ODYOVにジャンプ
- #00DA #6600
- #00DB #00DE
-../../../../as/FUNC/outa.casl: 62: JUMP ODSL ; ループ終端
- #00DC #6400
- #00DD #00D3
-../../../../as/FUNC/outa.casl: 63:ODYOV SRL GR2,1
- #00DE #5320
- #00DF #0001
-../../../../as/FUNC/outa.casl: 64: LAD GR2,#8000,GR2
- #00E0 #1222
- #00E1 #8000
-../../../../as/FUNC/outa.casl: 65: SRL GR4,1
- #00E2 #5340
- #00E3 #0001
-../../../../as/FUNC/outa.casl: 66: JUMP ODLPIN
- #00E4 #6400
- #00E5 #00F3
-../../../../as/FUNC/outa.casl: 67:ODLOOP SRL GR4,1 ; ループ先頭。GR4を1回右シフト
- #00E6 #5340
- #00E7 #0001
-../../../../as/FUNC/outa.casl: 68: JZE ODFIN ; (GR4 = 0)の場合、ループ脱出
- #00E8 #6300
- #00E9 #00F7
-../../../../as/FUNC/outa.casl: 69: SRL GR2,1 ; GR2を1回右シフト
- #00EA #5320
- #00EB #0001
-../../../../as/FUNC/outa.casl: 70: CPL GR1,ODY ; (GR1 < ODY)の場合、ループ脱出
- #00EC #4110
- #00ED #00FC
-../../../../as/FUNC/outa.casl: 71: JMI ODFIN ; ↓
- #00EE #6100
- #00EF #00F7
-../../../../as/FUNC/outa.casl: 72: CPL GR1,GR2 ; (GR1 < GR2)の場合、ループ先頭へジャンプ
- #00F0 #4512
-../../../../as/FUNC/outa.casl: 73: JMI ODLOOP ; ↓
- #00F1 #6100
- #00F2 #00E6
-../../../../as/FUNC/outa.casl: 74:ODLPIN SUBL GR1,GR2 ; GR1 <- GR1 - GR2
- #00F3 #2712
-../../../../as/FUNC/outa.casl: 75: ADDL GR0,GR4 ; GR0 <- GR0 + GR4
- #00F4 #2604
-../../../../as/FUNC/outa.casl: 76: JUMP ODLOOP ; ループ終端
- #00F5 #6400
- #00F6 #00E6
-../../../../as/FUNC/outa.casl: 77:ODFIN LD GR3,GR1
- #00F7 #1431
-../../../../as/FUNC/outa.casl: 78: POP GR4
- #00F8 #7140
-../../../../as/FUNC/outa.casl: 79: POP GR2
- #00F9 #7120
-../../../../as/FUNC/outa.casl: 80: POP GR1
- #00FA #7110
-../../../../as/FUNC/outa.casl: 81: RET
- #00FB #8100
-../../../../as/FUNC/outa.casl: 82:ODY DS 1
- #00FC #0000
-../../../../as/FUNC/outa.casl: 83: END
-../../../../as/FUNC/outa.casl: 84:;; アドレスがGR1、長さがGR2の文字列を逆順に並べ替える
-../../../../as/FUNC/outa.casl: 85:;; 例: 12345 -> 54321、54321- -> -12345
-../../../../as/FUNC/outa.casl: 86:REV START
-../../../../as/FUNC/outa.casl: 87: RPUSH
- #00FD #7001
- #00FE #0000
- #00FF #7002
- #0100 #0000
- #0101 #7003
- #0102 #0000
- #0103 #7004
- #0104 #0000
- #0105 #7005
- #0106 #0000
- #0107 #7006
- #0108 #0000
- #0109 #7007
- #010A #0000
-../../../../as/FUNC/outa.casl: 88: LAD GR3,0 ; GR3の初期化
- #010B #1230
- #010C #0000
-../../../../as/FUNC/outa.casl: 89:RPU CPL GR3,GR2 ; ループ先頭。(GR3 = GR2)の場合、ループ脱出
- #010D #4532
-../../../../as/FUNC/outa.casl: 90: JZE RNEXT ; ↓
- #010E #6300
- #010F #011A
-../../../../as/FUNC/outa.casl: 91: LD GR4,GR1 ; GR4にGR1の値をコピー
- #0110 #1441
-../../../../as/FUNC/outa.casl: 92: ADDL GR4,GR3 ; GR4 <- GR4 + GR3
- #0111 #2643
-../../../../as/FUNC/outa.casl: 93: LD GR5,0,GR4 ; GR5にアドレスGR4の値を格納
- #0112 #1054
- #0113 #0000
-../../../../as/FUNC/outa.casl: 94: PUSH 0,GR5 ; GR5をプッシュ
- #0114 #7005
- #0115 #0000
-../../../../as/FUNC/outa.casl: 95: LAD GR3,1,GR3 ; GR3 <- GR3 + 1
- #0116 #1233
- #0117 #0001
-../../../../as/FUNC/outa.casl: 96: JUMP RPU ; ループ終端
- #0118 #6400
- #0119 #010D
-../../../../as/FUNC/outa.casl: 97:RNEXT LAD GR3,0 ; GR3の初期化
- #011A #1230
- #011B #0000
-../../../../as/FUNC/outa.casl: 98:RPO CPL GR3,GR2 ; ループ先頭。(GR3 = GR2)の場合、ループ脱出
- #011C #4532
-../../../../as/FUNC/outa.casl: 99: JZE RFIN ; ↓
- #011D #6300
- #011E #0128
-../../../../as/FUNC/outa.casl: 100: POP GR5 ; GR5にポップ
- #011F #7150
-../../../../as/FUNC/outa.casl: 101: LD GR4,GR1 ; GR4にGR1の値をコピー
- #0120 #1441
-../../../../as/FUNC/outa.casl: 102: ADDL GR4,GR3 ; GR4 <- GR4 + GR3
- #0121 #2643
-../../../../as/FUNC/outa.casl: 103: ST GR5,0,GR4 ; アドレスGR4にGR5の値を格納
- #0122 #1154
- #0123 #0000
-../../../../as/FUNC/outa.casl: 104: LAD GR3,1,GR3 ; GR3 <- GR3 + 1
- #0124 #1233
- #0125 #0001
-../../../../as/FUNC/outa.casl: 105: JUMP RPO ; ループ終端
- #0126 #6400
- #0127 #011C
-../../../../as/FUNC/outa.casl: 106:RFIN RPOP
- #0128 #7170
- #0129 #7160
- #012A #7150
- #012B #7140
- #012C #7130
- #012D #7120
- #012E #7110
-../../../../as/FUNC/outa.casl: 107: RET
- #012F #8100
-../../../../as/FUNC/outa.casl: 108: END
-../../../../as/FUNC/outa.casl: 109:;; GR1の値を絶対値に変換する。GR1にはマイナスの数値が格納されていると想定。
-../../../../as/FUNC/outa.casl: 110:;; 例: -10 -> 10, -20 -> 20
-../../../../as/FUNC/outa.casl: 111:OABS START
-../../../../as/FUNC/outa.casl: 112: XOR GR1,=#FFFF ; GR1の値を反転
- #0137 #FFFF
- #0130 #3210
- #0131 #0137
-../../../../as/FUNC/outa.casl: 113: LAD GR1,1,GR1 ; GR1 <- GR1 + 1
- #0132 #1211
- #0133 #0001
-../../../../as/FUNC/outa.casl: 114: RET
- #0134 #8100
-../../../../as/FUNC/outa.casl: 115: END
+../../../../casl2 ../../../../as/FUNC/count1_call.casl ../../../../as/FUNC/count1.casl ../../../../as/FUNC/outa.casl
0
1
1
include ../CMD.mk # YACASL2DIR, CASL2
-CASL2FLAG = -sla
ASDIR = $(YACASL2DIR)/as/FUNC
ASFILE = $(ASDIR)/count1_call.casl $(ASDIR)/count1.casl $(ASDIR)/outa.casl
-CMD = $(CASL2) $(CASL2FLAG) $(ASFILE) $(IN)
+CMD = $(CASL2) $(ASFILE)
include ../TEST.mk
-../../../../casl2 ../../../../as/FUNC/divl_call.casl ../../../../as/FUNC/divl0.casl ../../../../as/FUNC/outl.casl
+../../../../casl2 ../../../../as/FUNC/divl_call.casl ../../../../as/FUNC/divl0.casl ../../../../as/FUNC/outl_main.casl ../../../../as/FUNC/rev.casl
--------------------
100
0
include ../CMD.mk # YACASL2DIR, CASL2
ASDIR = $(YACASL2DIR)/as/FUNC
-ASFILE = $(ASDIR)/divl_call.casl $(ASDIR)/divl0.casl $(ASDIR)/outl.casl
+ASFILE = $(ASDIR)/divl_call.casl $(ASDIR)/divl0.casl $(ASDIR)/outl_main.casl $(ASDIR)/rev.casl
CMD = $(CASL2) $(ASFILE)
include ../TEST.mk
-../../../../casl2 ../../../../as/FUNC/divl_call.casl ../../../../as/FUNC/divl1.casl ../../../../as/FUNC/outl.casl
+../../../../casl2 ../../../../as/FUNC/divl_call.casl ../../../../as/FUNC/divl1.casl ../../../../as/FUNC/outl_main.casl ../../../../as/FUNC/rev.casl
--------------------
100
0
include ../CMD.mk # YACASL2DIR, CASL2
ASDIR = $(YACASL2DIR)/as/FUNC
-ASFILE = $(ASDIR)/divl_call.casl $(ASDIR)/divl1.casl $(ASDIR)/outl.casl
+ASFILE = $(ASDIR)/divl_call.casl $(ASDIR)/divl1.casl $(ASDIR)/outl_main.casl $(ASDIR)/rev.casl
CMD = $(CASL2) $(ASFILE)
include ../TEST.mk
-../../../../casl2 -sla ../../../../as/FUNC/minim_call.casl ../../../../as/FUNC/minim.casl ../../../../as/FUNC/outa.casl
-
-Assemble ../../../../as/FUNC/minim_call.casl (0)
-../../../../as/FUNC/minim_call.casl: 1:;;; casl2 minim_call.casl minim.casl outa.casl
-../../../../as/FUNC/minim_call.casl: 2:MAIN START
-../../../../as/FUNC/minim_call.casl: 3: LAD GR1,DATA
-../../../../as/FUNC/minim_call.casl: 4: LD GR2,CNT
-../../../../as/FUNC/minim_call.casl: 5: CALL MINIM
-../../../../as/FUNC/minim_call.casl: 6: LD GR1,GR0
-../../../../as/FUNC/minim_call.casl: 7: CALL OUTA
-../../../../as/FUNC/minim_call.casl: 8: RET
-../../../../as/FUNC/minim_call.casl: 9:DATA DC 23,78,2,45,67,-39,86
-../../../../as/FUNC/minim_call.casl: 10:CNT DC 7
-../../../../as/FUNC/minim_call.casl: 11: END
-
-Assemble ../../../../as/FUNC/minim.casl (0)
-../../../../as/FUNC/minim.casl: 1:;;; GR1のアドレスに格納されたGR2の個数の値の中で、最小値をGR0に格納する
-../../../../as/FUNC/minim.casl: 2:MINIM START
-../../../../as/FUNC/minim.casl: 3: LD GR0,0,GR1
-../../../../as/FUNC/minim.casl: 4: ST GR0,MIN
-../../../../as/FUNC/minim.casl: 5: LAD GR3,0
-../../../../as/FUNC/minim.casl: 6:S1 CPA GR3,GR2
-../../../../as/FUNC/minim.casl: 7: JZE LRET
-../../../../as/FUNC/minim.casl: 8: LAD GR1,1,GR1
-../../../../as/FUNC/minim.casl: 9: LD GR0,0,GR1
-../../../../as/FUNC/minim.casl: 10: CPA GR0,MIN
-../../../../as/FUNC/minim.casl: 11: JPL S2
-../../../../as/FUNC/minim.casl: 12: JZE S2
-../../../../as/FUNC/minim.casl: 13: ST GR0,MIN
-../../../../as/FUNC/minim.casl: 14:S2 LAD GR3,1,GR3
-../../../../as/FUNC/minim.casl: 15: JUMP S1
-../../../../as/FUNC/minim.casl: 16:LRET LD GR0,MIN
-../../../../as/FUNC/minim.casl: 17: RET
-../../../../as/FUNC/minim.casl: 18:MIN DS 1
-../../../../as/FUNC/minim.casl: 19: END
-
-Assemble ../../../../as/FUNC/outa.casl (0)
-../../../../as/FUNC/outa.casl: 1:;;; GR1に格納された値を、10進数の整数値(-32768〜32767)として表示
-../../../../as/FUNC/outa.casl: 2:OUTA START
-../../../../as/FUNC/outa.casl: 3: RPUSH
-../../../../as/FUNC/outa.casl: 4: LAD GR2,10 ; GR2に10進数の「10」を格納。
-../../../../as/FUNC/outa.casl: 5: LAD GR0,0 ; GR0 <- 0
-../../../../as/FUNC/outa.casl: 6: LAD GR4,0 ; 負数フラグ。GR1が負数の場合、GR4は1
-../../../../as/FUNC/outa.casl: 7: LAD GR5,0 ; 整数値の長さ
-../../../../as/FUNC/outa.casl: 8: AND GR1,GR1 ; GR1をテスト
-../../../../as/FUNC/outa.casl: 9: JZE ZPRT ; GR1が0の場合、ZPRTにジャンプ
-../../../../as/FUNC/outa.casl: 10: JPL STI ; GR1が正数の場合、STIにジャンプ
-../../../../as/FUNC/outa.casl: 11: LAD GR4,1 ; GR1が負数の場合、GR4をオン
-../../../../as/FUNC/outa.casl: 12: CALL OABS ; GR1を正数に変換
-../../../../as/FUNC/outa.casl: 13:STI CPL GR1,GR2 ; ループ先頭。(GR1 < GR2)の場合は、ループ脱出
-../../../../as/FUNC/outa.casl: 14: JMI STLST ; ↓
-../../../../as/FUNC/outa.casl: 15: CALL ODIVL ; GR1とGR2の、商をGR0、剰余をGR3に格納
-../../../../as/FUNC/outa.casl: 16: LD GR1,GR3 ; GR1にGR3をコピー
-../../../../as/FUNC/outa.casl: 17: LD GR1,NCHAR,GR1 ; GR1を文字に変換
-../../../../as/FUNC/outa.casl: 18: ST GR1,STR,GR5 ; (STR + GR5) <- GR1
-../../../../as/FUNC/outa.casl: 19: LAD GR5,1,GR5 ; GR5 <- GR5 + 1
-../../../../as/FUNC/outa.casl: 20: LD GR1,GR0 ; GR0をGR1にコピー
-../../../../as/FUNC/outa.casl: 21: JUMP STI ; ループ終端
-../../../../as/FUNC/outa.casl: 22:STLST LD GR1,NCHAR,GR1 ; GR1を文字に変換
-../../../../as/FUNC/outa.casl: 23: ST GR1,STR,GR5 ; (STR + GR5) <- GR1
-../../../../as/FUNC/outa.casl: 24: LAD GR5,1,GR5 ; GR5 <- GR5 + 1
-../../../../as/FUNC/outa.casl: 25: AND GR4,GR4 ; 正数の場合
-../../../../as/FUNC/outa.casl: 26: JZE PRT ; ↓
-../../../../as/FUNC/outa.casl: 27: LD GR1,='-' ; 負数の場合、「-」をSTR領域に格納
-../../../../as/FUNC/outa.casl: 28: ST GR1,STR,GR5 ; (STR + GR5) <- GR1
-../../../../as/FUNC/outa.casl: 29: LAD GR5,1,GR5 ; GR5 <- GR5 + 1
-../../../../as/FUNC/outa.casl: 30: JUMP PRT ; PRTにジャンプ
-../../../../as/FUNC/outa.casl: 31:ZPRT LD GR1,NCHAR ; 「0」をSTR領域に格納
-../../../../as/FUNC/outa.casl: 32: ST GR1,STR,GR5 ; (STR + GR5) <- GR1
-../../../../as/FUNC/outa.casl: 33: LAD GR5,1,GR5 ; GR5 <- GR5 + 1
-../../../../as/FUNC/outa.casl: 34:PRT ST GR5,LEN ; LEN <- GR5
-../../../../as/FUNC/outa.casl: 35: LD GR2,LEN ; GR2にLENの値を格納
-../../../../as/FUNC/outa.casl: 36: LAD GR1,STR ; GR1に文字列のアドレスを格納
-../../../../as/FUNC/outa.casl: 37: CALL REV ; 文字列を逆順に並べ替え
-../../../../as/FUNC/outa.casl: 38: OUT STR,LEN ; 文字列を出力
-../../../../as/FUNC/outa.casl: 39: RPOP
-../../../../as/FUNC/outa.casl: 40: RET
-../../../../as/FUNC/outa.casl: 41:STR DS 17
-../../../../as/FUNC/outa.casl: 42:LEN DS 1
-../../../../as/FUNC/outa.casl: 43:NCHAR DC '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-../../../../as/FUNC/outa.casl: 44: END
-../../../../as/FUNC/outa.casl: 45:;;; GR1の値とGR2の値の、商をGR0、剰余をGR3に格納する
-../../../../as/FUNC/outa.casl: 46:;;; 0〜65535の範囲の数値を扱う
-../../../../as/FUNC/outa.casl: 47:ODIVL START
-../../../../as/FUNC/outa.casl: 48: PUSH 0,GR1
-../../../../as/FUNC/outa.casl: 49: PUSH 0,GR2
-../../../../as/FUNC/outa.casl: 50: PUSH 0,GR4
-../../../../as/FUNC/outa.casl: 51: AND GR2,GR2 ; GR2が0の場合、ODFINへジャンプ
-../../../../as/FUNC/outa.casl: 52: JZE ODFIN ; ↓
-../../../../as/FUNC/outa.casl: 53: ST GR2,ODY ; ODYにGR2の初期値を保存
-../../../../as/FUNC/outa.casl: 54: LAD GR0,0 ; GR0の初期化
-../../../../as/FUNC/outa.casl: 55: LAD GR3,0 ; GR3の初期化
-../../../../as/FUNC/outa.casl: 56: LAD GR4,1 ; GR4の初期化。対象ビットを表す
-../../../../as/FUNC/outa.casl: 57:ODSL CPL GR2,GR1 ; ループ先頭。(GR2 > GR1)の場合、ODLOOPへループ脱出
-../../../../as/FUNC/outa.casl: 58: JPL ODLOOP ; ↓
-../../../../as/FUNC/outa.casl: 59: SLL GR4,1 ; GR4を1回左シフト
-../../../../as/FUNC/outa.casl: 60: SLL GR2,1 ; GR2を1回左シフト
-../../../../as/FUNC/outa.casl: 61: JOV ODYOV ; オーバーフローの場合は、ODYOVにジャンプ
-../../../../as/FUNC/outa.casl: 62: JUMP ODSL ; ループ終端
-../../../../as/FUNC/outa.casl: 63:ODYOV SRL GR2,1
-../../../../as/FUNC/outa.casl: 64: LAD GR2,#8000,GR2
-../../../../as/FUNC/outa.casl: 65: SRL GR4,1
-../../../../as/FUNC/outa.casl: 66: JUMP ODLPIN
-../../../../as/FUNC/outa.casl: 67:ODLOOP SRL GR4,1 ; ループ先頭。GR4を1回右シフト
-../../../../as/FUNC/outa.casl: 68: JZE ODFIN ; (GR4 = 0)の場合、ループ脱出
-../../../../as/FUNC/outa.casl: 69: SRL GR2,1 ; GR2を1回右シフト
-../../../../as/FUNC/outa.casl: 70: CPL GR1,ODY ; (GR1 < ODY)の場合、ループ脱出
-../../../../as/FUNC/outa.casl: 71: JMI ODFIN ; ↓
-../../../../as/FUNC/outa.casl: 72: CPL GR1,GR2 ; (GR1 < GR2)の場合、ループ先頭へジャンプ
-../../../../as/FUNC/outa.casl: 73: JMI ODLOOP ; ↓
-../../../../as/FUNC/outa.casl: 74:ODLPIN SUBL GR1,GR2 ; GR1 <- GR1 - GR2
-../../../../as/FUNC/outa.casl: 75: ADDL GR0,GR4 ; GR0 <- GR0 + GR4
-../../../../as/FUNC/outa.casl: 76: JUMP ODLOOP ; ループ終端
-../../../../as/FUNC/outa.casl: 77:ODFIN LD GR3,GR1
-../../../../as/FUNC/outa.casl: 78: POP GR4
-../../../../as/FUNC/outa.casl: 79: POP GR2
-../../../../as/FUNC/outa.casl: 80: POP GR1
-../../../../as/FUNC/outa.casl: 81: RET
-../../../../as/FUNC/outa.casl: 82:ODY DS 1
-../../../../as/FUNC/outa.casl: 83: END
-../../../../as/FUNC/outa.casl: 84:;; アドレスがGR1、長さがGR2の文字列を逆順に並べ替える
-../../../../as/FUNC/outa.casl: 85:;; 例: 12345 -> 54321、54321- -> -12345
-../../../../as/FUNC/outa.casl: 86:REV START
-../../../../as/FUNC/outa.casl: 87: RPUSH
-../../../../as/FUNC/outa.casl: 88: LAD GR3,0 ; GR3の初期化
-../../../../as/FUNC/outa.casl: 89:RPU CPL GR3,GR2 ; ループ先頭。(GR3 = GR2)の場合、ループ脱出
-../../../../as/FUNC/outa.casl: 90: JZE RNEXT ; ↓
-../../../../as/FUNC/outa.casl: 91: LD GR4,GR1 ; GR4にGR1の値をコピー
-../../../../as/FUNC/outa.casl: 92: ADDL GR4,GR3 ; GR4 <- GR4 + GR3
-../../../../as/FUNC/outa.casl: 93: LD GR5,0,GR4 ; GR5にアドレスGR4の値を格納
-../../../../as/FUNC/outa.casl: 94: PUSH 0,GR5 ; GR5をプッシュ
-../../../../as/FUNC/outa.casl: 95: LAD GR3,1,GR3 ; GR3 <- GR3 + 1
-../../../../as/FUNC/outa.casl: 96: JUMP RPU ; ループ終端
-../../../../as/FUNC/outa.casl: 97:RNEXT LAD GR3,0 ; GR3の初期化
-../../../../as/FUNC/outa.casl: 98:RPO CPL GR3,GR2 ; ループ先頭。(GR3 = GR2)の場合、ループ脱出
-../../../../as/FUNC/outa.casl: 99: JZE RFIN ; ↓
-../../../../as/FUNC/outa.casl: 100: POP GR5 ; GR5にポップ
-../../../../as/FUNC/outa.casl: 101: LD GR4,GR1 ; GR4にGR1の値をコピー
-../../../../as/FUNC/outa.casl: 102: ADDL GR4,GR3 ; GR4 <- GR4 + GR3
-../../../../as/FUNC/outa.casl: 103: ST GR5,0,GR4 ; アドレスGR4にGR5の値を格納
-../../../../as/FUNC/outa.casl: 104: LAD GR3,1,GR3 ; GR3 <- GR3 + 1
-../../../../as/FUNC/outa.casl: 105: JUMP RPO ; ループ終端
-../../../../as/FUNC/outa.casl: 106:RFIN RPOP
-../../../../as/FUNC/outa.casl: 107: RET
-../../../../as/FUNC/outa.casl: 108: END
-../../../../as/FUNC/outa.casl: 109:;; GR1の値を絶対値に変換する。GR1にはマイナスの数値が格納されていると想定。
-../../../../as/FUNC/outa.casl: 110:;; 例: -10 -> 10, -20 -> 20
-../../../../as/FUNC/outa.casl: 111:OABS START
-../../../../as/FUNC/outa.casl: 112: XOR GR1,=#FFFF ; GR1の値を反転
-../../../../as/FUNC/outa.casl: 113: LAD GR1,1,GR1 ; GR1 <- GR1 + 1
-../../../../as/FUNC/outa.casl: 114: RET
-../../../../as/FUNC/outa.casl: 115: END
-
-Label::::
-ODIVL.ODY ---> #0106
-OUTA.LEN ---> #00A7
-ODIVL.ODLOOP ---> #00F0
-ODIVL.ODLPIN ---> #00FD
-OUTA.ZPRT ---> #006E
-OUTA.STI ---> #004E
-REV.RFIN ---> #0132
-OUTA.STR ---> #0096
-ODIVL.ODFIN ---> #0101
-REV.RPO ---> #0126
-REV.RPU ---> #0117
-ODIVL.ODYOV ---> #00E8
-REV ---> #0107
-MINIM.LRET ---> #002B
-MINIM.S1 ---> #0018
-MINIM.S2 ---> #0027
-MINIM.MIN ---> #002E
-REV.RNEXT ---> #0124
-OABS ---> #013A
-OUTA.NCHAR ---> #00A8
-ODIVL.ODSL ---> #00DD
-OUTA.STLST ---> #005D
-MAIN ---> #0000
-ODIVL ---> #00CC
-OUTA ---> #002F
-MINIM ---> #0012
-OUTA.PRT ---> #0074
-MAIN.DATA ---> #000A
-MAIN.CNT ---> #0011
-
-Assemble ../../../../as/FUNC/minim_call.casl (1)
-../../../../as/FUNC/minim_call.casl: 1:;;; casl2 minim_call.casl minim.casl outa.casl
-../../../../as/FUNC/minim_call.casl: 2:MAIN START
-../../../../as/FUNC/minim_call.casl: 3: LAD GR1,DATA
- #0000 #1210
- #0001 #000A
-../../../../as/FUNC/minim_call.casl: 4: LD GR2,CNT
- #0002 #1020
- #0003 #0011
-../../../../as/FUNC/minim_call.casl: 5: CALL MINIM
- #0004 #8000
- #0005 #0012
-../../../../as/FUNC/minim_call.casl: 6: LD GR1,GR0
- #0006 #1410
-../../../../as/FUNC/minim_call.casl: 7: CALL OUTA
- #0007 #8000
- #0008 #002F
-../../../../as/FUNC/minim_call.casl: 8: RET
- #0009 #8100
-../../../../as/FUNC/minim_call.casl: 9:DATA DC 23,78,2,45,67,-39,86
- #000A #0017
- #000B #004E
- #000C #0002
- #000D #002D
- #000E #0043
- #000F #FFD9
- #0010 #0056
-../../../../as/FUNC/minim_call.casl: 10:CNT DC 7
- #0011 #0007
-../../../../as/FUNC/minim_call.casl: 11: END
-
-Assemble ../../../../as/FUNC/minim.casl (1)
-../../../../as/FUNC/minim.casl: 1:;;; GR1のアドレスに格納されたGR2の個数の値の中で、最小値をGR0に格納する
-../../../../as/FUNC/minim.casl: 2:MINIM START
-../../../../as/FUNC/minim.casl: 3: LD GR0,0,GR1
- #0012 #1001
- #0013 #0000
-../../../../as/FUNC/minim.casl: 4: ST GR0,MIN
- #0014 #1100
- #0015 #002E
-../../../../as/FUNC/minim.casl: 5: LAD GR3,0
- #0016 #1230
- #0017 #0000
-../../../../as/FUNC/minim.casl: 6:S1 CPA GR3,GR2
- #0018 #4432
-../../../../as/FUNC/minim.casl: 7: JZE LRET
- #0019 #6300
- #001A #002B
-../../../../as/FUNC/minim.casl: 8: LAD GR1,1,GR1
- #001B #1211
- #001C #0001
-../../../../as/FUNC/minim.casl: 9: LD GR0,0,GR1
- #001D #1001
- #001E #0000
-../../../../as/FUNC/minim.casl: 10: CPA GR0,MIN
- #001F #4000
- #0020 #002E
-../../../../as/FUNC/minim.casl: 11: JPL S2
- #0021 #6500
- #0022 #0027
-../../../../as/FUNC/minim.casl: 12: JZE S2
- #0023 #6300
- #0024 #0027
-../../../../as/FUNC/minim.casl: 13: ST GR0,MIN
- #0025 #1100
- #0026 #002E
-../../../../as/FUNC/minim.casl: 14:S2 LAD GR3,1,GR3
- #0027 #1233
- #0028 #0001
-../../../../as/FUNC/minim.casl: 15: JUMP S1
- #0029 #6400
- #002A #0018
-../../../../as/FUNC/minim.casl: 16:LRET LD GR0,MIN
- #002B #1000
- #002C #002E
-../../../../as/FUNC/minim.casl: 17: RET
- #002D #8100
-../../../../as/FUNC/minim.casl: 18:MIN DS 1
- #002E #0000
-../../../../as/FUNC/minim.casl: 19: END
-
-Assemble ../../../../as/FUNC/outa.casl (1)
-../../../../as/FUNC/outa.casl: 1:;;; GR1に格納された値を、10進数の整数値(-32768〜32767)として表示
-../../../../as/FUNC/outa.casl: 2:OUTA START
-../../../../as/FUNC/outa.casl: 3: RPUSH
- #002F #7001
- #0030 #0000
- #0031 #7002
- #0032 #0000
- #0033 #7003
- #0034 #0000
- #0035 #7004
- #0036 #0000
- #0037 #7005
- #0038 #0000
- #0039 #7006
- #003A #0000
- #003B #7007
- #003C #0000
-../../../../as/FUNC/outa.casl: 4: LAD GR2,10 ; GR2に10進数の「10」を格納。
- #003D #1220
- #003E #000A
-../../../../as/FUNC/outa.casl: 5: LAD GR0,0 ; GR0 <- 0
- #003F #1200
- #0040 #0000
-../../../../as/FUNC/outa.casl: 6: LAD GR4,0 ; 負数フラグ。GR1が負数の場合、GR4は1
- #0041 #1240
- #0042 #0000
-../../../../as/FUNC/outa.casl: 7: LAD GR5,0 ; 整数値の長さ
- #0043 #1250
- #0044 #0000
-../../../../as/FUNC/outa.casl: 8: AND GR1,GR1 ; GR1をテスト
- #0045 #3411
-../../../../as/FUNC/outa.casl: 9: JZE ZPRT ; GR1が0の場合、ZPRTにジャンプ
- #0046 #6300
- #0047 #006E
-../../../../as/FUNC/outa.casl: 10: JPL STI ; GR1が正数の場合、STIにジャンプ
- #0048 #6500
- #0049 #004E
-../../../../as/FUNC/outa.casl: 11: LAD GR4,1 ; GR1が負数の場合、GR4をオン
- #004A #1240
- #004B #0001
-../../../../as/FUNC/outa.casl: 12: CALL OABS ; GR1を正数に変換
- #004C #8000
- #004D #013A
-../../../../as/FUNC/outa.casl: 13:STI CPL GR1,GR2 ; ループ先頭。(GR1 < GR2)の場合は、ループ脱出
- #004E #4512
-../../../../as/FUNC/outa.casl: 14: JMI STLST ; ↓
- #004F #6100
- #0050 #005D
-../../../../as/FUNC/outa.casl: 15: CALL ODIVL ; GR1とGR2の、商をGR0、剰余をGR3に格納
- #0051 #8000
- #0052 #00CC
-../../../../as/FUNC/outa.casl: 16: LD GR1,GR3 ; GR1にGR3をコピー
- #0053 #1413
-../../../../as/FUNC/outa.casl: 17: LD GR1,NCHAR,GR1 ; GR1を文字に変換
- #0054 #1011
- #0055 #00A8
-../../../../as/FUNC/outa.casl: 18: ST GR1,STR,GR5 ; (STR + GR5) <- GR1
- #0056 #1115
- #0057 #0096
-../../../../as/FUNC/outa.casl: 19: LAD GR5,1,GR5 ; GR5 <- GR5 + 1
- #0058 #1255
- #0059 #0001
-../../../../as/FUNC/outa.casl: 20: LD GR1,GR0 ; GR0をGR1にコピー
- #005A #1410
-../../../../as/FUNC/outa.casl: 21: JUMP STI ; ループ終端
- #005B #6400
- #005C #004E
-../../../../as/FUNC/outa.casl: 22:STLST LD GR1,NCHAR,GR1 ; GR1を文字に変換
- #005D #1011
- #005E #00A8
-../../../../as/FUNC/outa.casl: 23: ST GR1,STR,GR5 ; (STR + GR5) <- GR1
- #005F #1115
- #0060 #0096
-../../../../as/FUNC/outa.casl: 24: LAD GR5,1,GR5 ; GR5 <- GR5 + 1
- #0061 #1255
- #0062 #0001
-../../../../as/FUNC/outa.casl: 25: AND GR4,GR4 ; 正数の場合
- #0063 #3444
-../../../../as/FUNC/outa.casl: 26: JZE PRT ; ↓
- #0064 #6300
- #0065 #0074
-../../../../as/FUNC/outa.casl: 27: LD GR1,='-' ; 負数の場合、「-」をSTR領域に格納
- #013F #002D
- #0066 #1010
- #0067 #013F
-../../../../as/FUNC/outa.casl: 28: ST GR1,STR,GR5 ; (STR + GR5) <- GR1
- #0068 #1115
- #0069 #0096
-../../../../as/FUNC/outa.casl: 29: LAD GR5,1,GR5 ; GR5 <- GR5 + 1
- #006A #1255
- #006B #0001
-../../../../as/FUNC/outa.casl: 30: JUMP PRT ; PRTにジャンプ
- #006C #6400
- #006D #0074
-../../../../as/FUNC/outa.casl: 31:ZPRT LD GR1,NCHAR ; 「0」をSTR領域に格納
- #006E #1010
- #006F #00A8
-../../../../as/FUNC/outa.casl: 32: ST GR1,STR,GR5 ; (STR + GR5) <- GR1
- #0070 #1115
- #0071 #0096
-../../../../as/FUNC/outa.casl: 33: LAD GR5,1,GR5 ; GR5 <- GR5 + 1
- #0072 #1255
- #0073 #0001
-../../../../as/FUNC/outa.casl: 34:PRT ST GR5,LEN ; LEN <- GR5
- #0074 #1150
- #0075 #00A7
-../../../../as/FUNC/outa.casl: 35: LD GR2,LEN ; GR2にLENの値を格納
- #0076 #1020
- #0077 #00A7
-../../../../as/FUNC/outa.casl: 36: LAD GR1,STR ; GR1に文字列のアドレスを格納
- #0078 #1210
- #0079 #0096
-../../../../as/FUNC/outa.casl: 37: CALL REV ; 文字列を逆順に並べ替え
- #007A #8000
- #007B #0107
-../../../../as/FUNC/outa.casl: 38: OUT STR,LEN ; 文字列を出力
- #007C #7001
- #007D #0000
- #007E #7002
- #007F #0000
- #0080 #1210
- #0081 #0096
- #0082 #1020
- #0083 #00A7
- #0084 #F000
- #0085 #0002
- #0086 #1210
- #0087 #0140
- #0140 #000A
- #0088 #1220
- #0089 #0001
- #008A #F000
- #008B #0002
- #008C #7120
- #008D #7110
-../../../../as/FUNC/outa.casl: 39: RPOP
- #008E #7170
- #008F #7160
- #0090 #7150
- #0091 #7140
- #0092 #7130
- #0093 #7120
- #0094 #7110
-../../../../as/FUNC/outa.casl: 40: RET
- #0095 #8100
-../../../../as/FUNC/outa.casl: 41:STR DS 17
- #0096 #0000
- #0097 #0000
- #0098 #0000
- #0099 #0000
- #009A #0000
- #009B #0000
- #009C #0000
- #009D #0000
- #009E #0000
- #009F #0000
- #00A0 #0000
- #00A1 #0000
- #00A2 #0000
- #00A3 #0000
- #00A4 #0000
- #00A5 #0000
- #00A6 #0000
-../../../../as/FUNC/outa.casl: 42:LEN DS 1
- #00A7 #0000
-../../../../as/FUNC/outa.casl: 43:NCHAR DC '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
- #00A8 #0030
- #00A9 #0031
- #00AA #0032
- #00AB #0033
- #00AC #0034
- #00AD #0035
- #00AE #0036
- #00AF #0037
- #00B0 #0038
- #00B1 #0039
- #00B2 #0041
- #00B3 #0042
- #00B4 #0043
- #00B5 #0044
- #00B6 #0045
- #00B7 #0046
- #00B8 #0047
- #00B9 #0048
- #00BA #0049
- #00BB #004A
- #00BC #004B
- #00BD #004C
- #00BE #004D
- #00BF #004E
- #00C0 #004F
- #00C1 #0050
- #00C2 #0051
- #00C3 #0052
- #00C4 #0053
- #00C5 #0054
- #00C6 #0055
- #00C7 #0056
- #00C8 #0057
- #00C9 #0058
- #00CA #0059
- #00CB #005A
-../../../../as/FUNC/outa.casl: 44: END
-../../../../as/FUNC/outa.casl: 45:;;; GR1の値とGR2の値の、商をGR0、剰余をGR3に格納する
-../../../../as/FUNC/outa.casl: 46:;;; 0〜65535の範囲の数値を扱う
-../../../../as/FUNC/outa.casl: 47:ODIVL START
-../../../../as/FUNC/outa.casl: 48: PUSH 0,GR1
- #00CC #7001
- #00CD #0000
-../../../../as/FUNC/outa.casl: 49: PUSH 0,GR2
- #00CE #7002
- #00CF #0000
-../../../../as/FUNC/outa.casl: 50: PUSH 0,GR4
- #00D0 #7004
- #00D1 #0000
-../../../../as/FUNC/outa.casl: 51: AND GR2,GR2 ; GR2が0の場合、ODFINへジャンプ
- #00D2 #3422
-../../../../as/FUNC/outa.casl: 52: JZE ODFIN ; ↓
- #00D3 #6300
- #00D4 #0101
-../../../../as/FUNC/outa.casl: 53: ST GR2,ODY ; ODYにGR2の初期値を保存
- #00D5 #1120
- #00D6 #0106
-../../../../as/FUNC/outa.casl: 54: LAD GR0,0 ; GR0の初期化
- #00D7 #1200
- #00D8 #0000
-../../../../as/FUNC/outa.casl: 55: LAD GR3,0 ; GR3の初期化
- #00D9 #1230
- #00DA #0000
-../../../../as/FUNC/outa.casl: 56: LAD GR4,1 ; GR4の初期化。対象ビットを表す
- #00DB #1240
- #00DC #0001
-../../../../as/FUNC/outa.casl: 57:ODSL CPL GR2,GR1 ; ループ先頭。(GR2 > GR1)の場合、ODLOOPへループ脱出
- #00DD #4521
-../../../../as/FUNC/outa.casl: 58: JPL ODLOOP ; ↓
- #00DE #6500
- #00DF #00F0
-../../../../as/FUNC/outa.casl: 59: SLL GR4,1 ; GR4を1回左シフト
- #00E0 #5240
- #00E1 #0001
-../../../../as/FUNC/outa.casl: 60: SLL GR2,1 ; GR2を1回左シフト
- #00E2 #5220
- #00E3 #0001
-../../../../as/FUNC/outa.casl: 61: JOV ODYOV ; オーバーフローの場合は、ODYOVにジャンプ
- #00E4 #6600
- #00E5 #00E8
-../../../../as/FUNC/outa.casl: 62: JUMP ODSL ; ループ終端
- #00E6 #6400
- #00E7 #00DD
-../../../../as/FUNC/outa.casl: 63:ODYOV SRL GR2,1
- #00E8 #5320
- #00E9 #0001
-../../../../as/FUNC/outa.casl: 64: LAD GR2,#8000,GR2
- #00EA #1222
- #00EB #8000
-../../../../as/FUNC/outa.casl: 65: SRL GR4,1
- #00EC #5340
- #00ED #0001
-../../../../as/FUNC/outa.casl: 66: JUMP ODLPIN
- #00EE #6400
- #00EF #00FD
-../../../../as/FUNC/outa.casl: 67:ODLOOP SRL GR4,1 ; ループ先頭。GR4を1回右シフト
- #00F0 #5340
- #00F1 #0001
-../../../../as/FUNC/outa.casl: 68: JZE ODFIN ; (GR4 = 0)の場合、ループ脱出
- #00F2 #6300
- #00F3 #0101
-../../../../as/FUNC/outa.casl: 69: SRL GR2,1 ; GR2を1回右シフト
- #00F4 #5320
- #00F5 #0001
-../../../../as/FUNC/outa.casl: 70: CPL GR1,ODY ; (GR1 < ODY)の場合、ループ脱出
- #00F6 #4110
- #00F7 #0106
-../../../../as/FUNC/outa.casl: 71: JMI ODFIN ; ↓
- #00F8 #6100
- #00F9 #0101
-../../../../as/FUNC/outa.casl: 72: CPL GR1,GR2 ; (GR1 < GR2)の場合、ループ先頭へジャンプ
- #00FA #4512
-../../../../as/FUNC/outa.casl: 73: JMI ODLOOP ; ↓
- #00FB #6100
- #00FC #00F0
-../../../../as/FUNC/outa.casl: 74:ODLPIN SUBL GR1,GR2 ; GR1 <- GR1 - GR2
- #00FD #2712
-../../../../as/FUNC/outa.casl: 75: ADDL GR0,GR4 ; GR0 <- GR0 + GR4
- #00FE #2604
-../../../../as/FUNC/outa.casl: 76: JUMP ODLOOP ; ループ終端
- #00FF #6400
- #0100 #00F0
-../../../../as/FUNC/outa.casl: 77:ODFIN LD GR3,GR1
- #0101 #1431
-../../../../as/FUNC/outa.casl: 78: POP GR4
- #0102 #7140
-../../../../as/FUNC/outa.casl: 79: POP GR2
- #0103 #7120
-../../../../as/FUNC/outa.casl: 80: POP GR1
- #0104 #7110
-../../../../as/FUNC/outa.casl: 81: RET
- #0105 #8100
-../../../../as/FUNC/outa.casl: 82:ODY DS 1
- #0106 #0000
-../../../../as/FUNC/outa.casl: 83: END
-../../../../as/FUNC/outa.casl: 84:;; アドレスがGR1、長さがGR2の文字列を逆順に並べ替える
-../../../../as/FUNC/outa.casl: 85:;; 例: 12345 -> 54321、54321- -> -12345
-../../../../as/FUNC/outa.casl: 86:REV START
-../../../../as/FUNC/outa.casl: 87: RPUSH
- #0107 #7001
- #0108 #0000
- #0109 #7002
- #010A #0000
- #010B #7003
- #010C #0000
- #010D #7004
- #010E #0000
- #010F #7005
- #0110 #0000
- #0111 #7006
- #0112 #0000
- #0113 #7007
- #0114 #0000
-../../../../as/FUNC/outa.casl: 88: LAD GR3,0 ; GR3の初期化
- #0115 #1230
- #0116 #0000
-../../../../as/FUNC/outa.casl: 89:RPU CPL GR3,GR2 ; ループ先頭。(GR3 = GR2)の場合、ループ脱出
- #0117 #4532
-../../../../as/FUNC/outa.casl: 90: JZE RNEXT ; ↓
- #0118 #6300
- #0119 #0124
-../../../../as/FUNC/outa.casl: 91: LD GR4,GR1 ; GR4にGR1の値をコピー
- #011A #1441
-../../../../as/FUNC/outa.casl: 92: ADDL GR4,GR3 ; GR4 <- GR4 + GR3
- #011B #2643
-../../../../as/FUNC/outa.casl: 93: LD GR5,0,GR4 ; GR5にアドレスGR4の値を格納
- #011C #1054
- #011D #0000
-../../../../as/FUNC/outa.casl: 94: PUSH 0,GR5 ; GR5をプッシュ
- #011E #7005
- #011F #0000
-../../../../as/FUNC/outa.casl: 95: LAD GR3,1,GR3 ; GR3 <- GR3 + 1
- #0120 #1233
- #0121 #0001
-../../../../as/FUNC/outa.casl: 96: JUMP RPU ; ループ終端
- #0122 #6400
- #0123 #0117
-../../../../as/FUNC/outa.casl: 97:RNEXT LAD GR3,0 ; GR3の初期化
- #0124 #1230
- #0125 #0000
-../../../../as/FUNC/outa.casl: 98:RPO CPL GR3,GR2 ; ループ先頭。(GR3 = GR2)の場合、ループ脱出
- #0126 #4532
-../../../../as/FUNC/outa.casl: 99: JZE RFIN ; ↓
- #0127 #6300
- #0128 #0132
-../../../../as/FUNC/outa.casl: 100: POP GR5 ; GR5にポップ
- #0129 #7150
-../../../../as/FUNC/outa.casl: 101: LD GR4,GR1 ; GR4にGR1の値をコピー
- #012A #1441
-../../../../as/FUNC/outa.casl: 102: ADDL GR4,GR3 ; GR4 <- GR4 + GR3
- #012B #2643
-../../../../as/FUNC/outa.casl: 103: ST GR5,0,GR4 ; アドレスGR4にGR5の値を格納
- #012C #1154
- #012D #0000
-../../../../as/FUNC/outa.casl: 104: LAD GR3,1,GR3 ; GR3 <- GR3 + 1
- #012E #1233
- #012F #0001
-../../../../as/FUNC/outa.casl: 105: JUMP RPO ; ループ終端
- #0130 #6400
- #0131 #0126
-../../../../as/FUNC/outa.casl: 106:RFIN RPOP
- #0132 #7170
- #0133 #7160
- #0134 #7150
- #0135 #7140
- #0136 #7130
- #0137 #7120
- #0138 #7110
-../../../../as/FUNC/outa.casl: 107: RET
- #0139 #8100
-../../../../as/FUNC/outa.casl: 108: END
-../../../../as/FUNC/outa.casl: 109:;; GR1の値を絶対値に変換する。GR1にはマイナスの数値が格納されていると想定。
-../../../../as/FUNC/outa.casl: 110:;; 例: -10 -> 10, -20 -> 20
-../../../../as/FUNC/outa.casl: 111:OABS START
-../../../../as/FUNC/outa.casl: 112: XOR GR1,=#FFFF ; GR1の値を反転
- #0141 #FFFF
- #013A #3210
- #013B #0141
-../../../../as/FUNC/outa.casl: 113: LAD GR1,1,GR1 ; GR1 <- GR1 + 1
- #013C #1211
- #013D #0001
-../../../../as/FUNC/outa.casl: 114: RET
- #013E #8100
-../../../../as/FUNC/outa.casl: 115: END
+../../../../casl2 ../../../../as/FUNC/minim_call.casl ../../../../as/FUNC/minim.casl ../../../../as/FUNC/outa.casl
-39
include ../CMD.mk # YACASL2DIR, CASL2
-CASL2FLAG = -sla
ASDIR = $(YACASL2DIR)/as/FUNC
-ASFILE = $(ASDIR)/minim_call.casl $(ASDIR)/minim.casl $(ASDIR)/outa.casl
-CMD = $(CASL2) $(CASL2FLAG) $(ASFILE) $(IN)
+ASFILE = $(ASDIR)/minim_call.casl $(ASDIR)/minim.casl $(ASDIR)/outa.casl
+CMD = $(CASL2) $(ASFILE)
include ../TEST.mk
check: clean report.txt
prepare: cleanall 0.txt $(OBJFILE)
clean:
- @rm -f 1.txt diff.txt report.txt
+ @rm -f 1.txt diff.txt report.txt $(OBJFILE)
cleanall: clean
@rm -f 0.txt $(OBJFILE)
$(OBJFILE): $(CASL2) $(ASFILE)
- @$(CASL2) $(CASL2FLAG) -O $(ASFILE) 2>$(ERRFILE)
+ @-$(CASL2) $(CASL2FLAG) -O $(ASFILE) 2>$(ERRFILE)
0.txt 1.txt: $(COMET2) $(OBJFILE)
@echo $(CMD) >$@; \
- $(CMD) >>$@ 2>$(ERRFILE); \
+ if test -s $(OBJFILE); then $(CMD) >>$@ 2>$(ERRFILE); fi; \
if test -s $(ERRFILE); then cat err.txt >>$@; else rm -f $(ERRFILE); fi
diff.txt: 1.txt
@-diff -c 0.txt 1.txt >$@ 2>&1
include ../CMD.mk # YACASL2DIR, CASL2
ASDIR = $(YACASL2DIR)/as/FUNC
-ASFILE = $(ASDIR)/abs_call.casl $(ASDIR)/abs.casl $(ASDIR)/outa.casl
+ASFILE = $(ASDIR)/abs_call.casl $(ASDIR)/abs.casl $(ASDIR)/outa_main.casl $(ASDIR)/divl1.casl $(ASDIR)/rev.casl
include ../TEST.mk
include ../CMD.mk # YACASL2DIR, CASL2
ASDIR = $(YACASL2DIR)/as/FUNC
-ASFILE = $(ASDIR)/divl_call.casl $(ASDIR)/divl0.casl $(ASDIR)/outl.casl
+ASFILE = $(ASDIR)/divl_call.casl $(ASDIR)/divl0.casl $(ASDIR)/outl_main.casl $(ASDIR)/rev.casl
include ../TEST.mk
include ../CMD.mk # YACASL2DIR, CASL2
ASDIR = $(YACASL2DIR)/as/FUNC
-ASFILE = $(ASDIR)/divl_call.casl $(ASDIR)/divl1.casl $(ASDIR)/outl.casl
+ASFILE = $(ASDIR)/divl_call.casl $(ASDIR)/divl1.casl $(ASDIR)/outl_main.casl $(ASDIR)/rev.casl
include ../TEST.mk