0e9b61bd386b265e1352aeb457bb7783f3b6f7e6
[YACASL2.git] / test / integration / casl2 / count_call / 0.txt
1 ../../../../casl2 -sla ../../../../as/FUNC/count1_call.casl ../../../../as/FUNC/count1.casl ../../../../as/FUNC/outa.casl
2
3 Assemble ../../../../as/FUNC/count1_call.casl (0)
4 ../../../../as/FUNC/count1_call.casl:1:;; count1.casl(「アセンブラ言語の仕様」プログラム例)を呼び出し、出力結果を表示
5 ../../../../as/FUNC/count1_call.casl:2:;; 使い方: casl2 count1_call.casl count1.casl outa.casl
6 ../../../../as/FUNC/count1_call.casl:3:MAIN    START
7 ../../../../as/FUNC/count1_call.casl:4:        LAD     GR2,0
8 ../../../../as/FUNC/count1_call.casl:5:LOOP    CPA     GR2,MAX         ; ループ開始。GR2がMAXの値になったらループ脱出
9 ../../../../as/FUNC/count1_call.casl:6:        JZE     FIN             ; ↓
10 ../../../../as/FUNC/count1_call.casl:7:        LD      GR1,GR2         ; GR1にVALの値をロード
11 ../../../../as/FUNC/count1_call.casl:8:        CALL    COUNT1          ; COUNT1を呼び出す。出力はGR0に格納
12 ../../../../as/FUNC/count1_call.casl:9:        LD      GR1,GR0         ; GR1にGR0の値をコピー
13 ../../../../as/FUNC/count1_call.casl:10:        CALL    OUTA            ; OUTAを呼び出す
14 ../../../../as/FUNC/count1_call.casl:11:        LAD     GR2,1,GR2       ; GR2 <= GR2 + 1
15 ../../../../as/FUNC/count1_call.casl:12:        JUMP    LOOP            ; ループ終端
16 ../../../../as/FUNC/count1_call.casl:13:FIN     RET
17 ../../../../as/FUNC/count1_call.casl:14:MAX     DC      256
18 ../../../../as/FUNC/count1_call.casl:15:        END
19
20 Assemble ../../../../as/FUNC/count1.casl (0)
21 ../../../../as/FUNC/count1.casl:1:COUNT1        START
22 ../../../../as/FUNC/count1.casl:2:;       入力    GR1:検索する語
23 ../../../../as/FUNC/count1.casl:3:;       処理    GR1中の'1'のビットの個数を求める
24 ../../../../as/FUNC/count1.casl:4:;       出力    GR0:GR1中の'1'のビットの個数
25 ../../../../as/FUNC/count1.casl:5:      PUSH    0,GR1
26 ../../../../as/FUNC/count1.casl:6:    PUSH      0,GR2
27 ../../../../as/FUNC/count1.casl:7:    SUBA      GR2,GR2
28 ../../../../as/FUNC/count1.casl:8:    AND               GR1,GR1
29 ../../../../as/FUNC/count1.casl:9:    JZE       RETURN
30 ../../../../as/FUNC/count1.casl:10:MORE LAD     GR2,1,GR2
31 ../../../../as/FUNC/count1.casl:11:     LAD             GR0,-1,GR1
32 ../../../../as/FUNC/count1.casl:12:    AND              GR1,GR0
33 ../../../../as/FUNC/count1.casl:13:    JNZ              MORE
34 ../../../../as/FUNC/count1.casl:14:RETURN LD    GR0,GR2
35 ../../../../as/FUNC/count1.casl:15:     POP             GR2
36 ../../../../as/FUNC/count1.casl:16:    POP              GR1
37 ../../../../as/FUNC/count1.casl:17:    RET
38 ../../../../as/FUNC/count1.casl:18:    END
39
40 Assemble ../../../../as/FUNC/outa.casl (0)
41 ../../../../as/FUNC/outa.casl:1:;;; GR1に格納された値を、10進数の整数値(-32768〜32767)として表示
42 ../../../../as/FUNC/outa.casl:2:OUTA    START
43 ../../../../as/FUNC/outa.casl:3:        RPUSH
44 ../../../../as/FUNC/outa.casl:4:        LAD     GR2,10          ; GR2に10進数の「10」を格納。
45 ../../../../as/FUNC/outa.casl:5:        LAD     GR0,0           ; GR0 <- 0
46 ../../../../as/FUNC/outa.casl:6:        LAD     GR4,0           ; 負数フラグ。GR1が負数の場合、GR4は1
47 ../../../../as/FUNC/outa.casl:7:        ST      GR0,LEN         ; LENの初期化
48 ../../../../as/FUNC/outa.casl:8:        AND     GR1,GR1         ; GR1をテスト
49 ../../../../as/FUNC/outa.casl:9:        JZE     ZPRT            ; GR1が0の場合、ZPRTにジャンプ
50 ../../../../as/FUNC/outa.casl:10:        JPL     STI             ; GR1が正数の場合、STIにジャンプ
51 ../../../../as/FUNC/outa.casl:11:        LAD     GR4,1           ; GR1が負数の場合、GR4をオン
52 ../../../../as/FUNC/outa.casl:12:        CALL    OABS            ;                  GR1を正数に変換
53 ../../../../as/FUNC/outa.casl:13:STI     CPL     GR1,GR2         ; ループ先頭。(GR1 < GR2)の場合は、ループ脱出
54 ../../../../as/FUNC/outa.casl:14:        JMI     STLST           ; ↓
55 ../../../../as/FUNC/outa.casl:15:        CALL    ODIVL           ; GR1とGR2の、商をGR0、剰余をGR3に格納
56 ../../../../as/FUNC/outa.casl:16:        LD      GR1,GR3         ; GR1にGR3をコピー
57 ../../../../as/FUNC/outa.casl:17:        LD      GR1,NCHAR,GR1   ; GR1を文字に変換
58 ../../../../as/FUNC/outa.casl:18:        CALL    STSTR           ; GR1をSTR領域に格納
59 ../../../../as/FUNC/outa.casl:19:        LD      GR1,GR0         ; GR0をGR1にコピー
60 ../../../../as/FUNC/outa.casl:20:        JUMP    STI             ; ループ終端
61 ../../../../as/FUNC/outa.casl:21:STLST   LD      GR1,NCHAR,GR1   ; GR1を文字に変換
62 ../../../../as/FUNC/outa.casl:22:        CALL    STSTR           ; GR1をSTR領域に格納
63 ../../../../as/FUNC/outa.casl:23:        AND     GR4,GR4         ; 正数の場合
64 ../../../../as/FUNC/outa.casl:24:        JZE     PRT             ; ↓
65 ../../../../as/FUNC/outa.casl:25:        LD      GR1,='-'        ; 負数の場合、「-」をSTR領域に格納
66 ../../../../as/FUNC/outa.casl:26:        CALL    STSTR           ; ↓
67 ../../../../as/FUNC/outa.casl:27:        JUMP    PRT             ; PRTにジャンプ
68 ../../../../as/FUNC/outa.casl:28:ZPRT    LD      GR1,NCHAR       ; 「0」をSTR領域に格納
69 ../../../../as/FUNC/outa.casl:29:        CALL    STSTR           ; ↓
70 ../../../../as/FUNC/outa.casl:30:PRT     LD      GR2,LEN         ; GR2にLENの値を格納
71 ../../../../as/FUNC/outa.casl:31:        LAD     GR1,STR         ; GR1に文字列のアドレスを格納
72 ../../../../as/FUNC/outa.casl:32:        CALL    REV             ; 文字列を逆順に並べ替え
73 ../../../../as/FUNC/outa.casl:33:        OUT     STR,LEN         ; 文字列を出力
74 ../../../../as/FUNC/outa.casl:34:        RPOP
75 ../../../../as/FUNC/outa.casl:35:        RET
76 ../../../../as/FUNC/outa.casl:36:STR     DS      17
77 ../../../../as/FUNC/outa.casl:37:LEN     DS      1
78 ../../../../as/FUNC/outa.casl:38:NCHAR   DC      '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
79 ../../../../as/FUNC/outa.casl:39:        END
80 ../../../../as/FUNC/outa.casl:40:;; GR1をSTR領域に格納し、LENをインクリメント
81 ../../../../as/FUNC/outa.casl:41:STSTR   START
82 ../../../../as/FUNC/outa.casl:42:        PUSH    0,GR1
83 ../../../../as/FUNC/outa.casl:43:        PUSH    0,GR2
84 ../../../../as/FUNC/outa.casl:44:        LD      GR2,LEN         ; GR2にLENの値をロード
85 ../../../../as/FUNC/outa.casl:45:        ST      GR1,STR,GR2     ; STR+GR2 <- GR1
86 ../../../../as/FUNC/outa.casl:46:        LAD     GR2,1,GR2       ; GR2 <- GR2 + 1
87 ../../../../as/FUNC/outa.casl:47:        ST      GR2,LEN         ; LENにGR2を格納
88 ../../../../as/FUNC/outa.casl:48:        POP     GR2
89 ../../../../as/FUNC/outa.casl:49:        POP     GR1
90 ../../../../as/FUNC/outa.casl:50:        RET
91 ../../../../as/FUNC/outa.casl:51:        END
92 ../../../../as/FUNC/outa.casl:52:;;; GR1の値とGR2の値の、商をGR0、剰余をGR3に格納する
93 ../../../../as/FUNC/outa.casl:53:;;; 0〜65535の範囲の数値を扱う
94 ../../../../as/FUNC/outa.casl:54:ODIVL   START
95 ../../../../as/FUNC/outa.casl:55:        PUSH    0,GR1
96 ../../../../as/FUNC/outa.casl:56:        PUSH    0,GR2
97 ../../../../as/FUNC/outa.casl:57:        PUSH    0,GR4
98 ../../../../as/FUNC/outa.casl:58:        AND     GR2,GR2         ; GR2が0の場合、ODFINへジャンプ
99 ../../../../as/FUNC/outa.casl:59:        JZE     ODFIN           ; ↓
100 ../../../../as/FUNC/outa.casl:60:        ST      GR2,ODY         ; ODYにGR2の初期値を保存
101 ../../../../as/FUNC/outa.casl:61:        LAD     GR0,0           ; GR0の初期化
102 ../../../../as/FUNC/outa.casl:62:        LAD     GR3,0           ; GR3の初期化
103 ../../../../as/FUNC/outa.casl:63:        LAD     GR4,1           ; GR4の初期化。対象ビットを表す
104 ../../../../as/FUNC/outa.casl:64:ODSL    CPL     GR2,GR1         ; ループ先頭。(GR2 > GR1)の場合、ODLOOPへループ脱出
105 ../../../../as/FUNC/outa.casl:65:        JPL     ODLOOP          ; ↓
106 ../../../../as/FUNC/outa.casl:66:        SLL     GR4,1           ; GR4を1回左シフト
107 ../../../../as/FUNC/outa.casl:67:        SLL     GR2,1           ; GR2を1回左シフト
108 ../../../../as/FUNC/outa.casl:68:        JOV     ODYOV           ; オーバーフローの場合は、ODYOVにジャンプ
109 ../../../../as/FUNC/outa.casl:69:        JUMP    ODSL            ; ループ終端
110 ../../../../as/FUNC/outa.casl:70:ODYOV   SRL     GR2,1
111 ../../../../as/FUNC/outa.casl:71:        LAD     GR2,#8000,GR2
112 ../../../../as/FUNC/outa.casl:72:        SRL     GR4,1
113 ../../../../as/FUNC/outa.casl:73:        JUMP    ODLPIN
114 ../../../../as/FUNC/outa.casl:74:ODLOOP  SRL     GR4,1           ; ループ先頭。GR4を1回右シフト
115 ../../../../as/FUNC/outa.casl:75:        JZE     ODFIN           ; (GR4 = 0)の場合、ループ脱出
116 ../../../../as/FUNC/outa.casl:76:        SRL     GR2,1           ; GR2を1回右シフト
117 ../../../../as/FUNC/outa.casl:77:        CPL     GR1,ODY         ; (GR1 < ODY)の場合、ループ脱出
118 ../../../../as/FUNC/outa.casl:78:        JMI     ODFIN           ; ↓
119 ../../../../as/FUNC/outa.casl:79:        CPL     GR1,GR2         ; (GR1 < GR2)の場合、ループ先頭へジャンプ
120 ../../../../as/FUNC/outa.casl:80:        JMI     ODLOOP          ; ↓
121 ../../../../as/FUNC/outa.casl:81:ODLPIN  SUBL    GR1,GR2         ; GR1 <- GR1 - GR2
122 ../../../../as/FUNC/outa.casl:82:        ADDL    GR0,GR4         ; GR0 <- GR0 + GR4
123 ../../../../as/FUNC/outa.casl:83:        JUMP    ODLOOP          ; ループ終端
124 ../../../../as/FUNC/outa.casl:84:ODFIN   LD      GR3,GR1
125 ../../../../as/FUNC/outa.casl:85:        POP    GR4
126 ../../../../as/FUNC/outa.casl:86:        POP     GR2
127 ../../../../as/FUNC/outa.casl:87:        POP     GR1
128 ../../../../as/FUNC/outa.casl:88:        RET
129 ../../../../as/FUNC/outa.casl:89:ODY     DS      1        
130 ../../../../as/FUNC/outa.casl:90:        END
131 ../../../../as/FUNC/outa.casl:91:;; アドレスがGR1、長さがGR2の文字列を逆順に並べ替える
132 ../../../../as/FUNC/outa.casl:92:;; 例: 12345 -> 54321、54321- -> -12345
133 ../../../../as/FUNC/outa.casl:93:REV     START
134 ../../../../as/FUNC/outa.casl:94:        RPUSH
135 ../../../../as/FUNC/outa.casl:95:        LAD     GR3,0           ; GR3の初期化
136 ../../../../as/FUNC/outa.casl:96:RPU     CPL     GR3,GR2         ; ループ先頭。(GR3 = GR2)の場合、ループ脱出
137 ../../../../as/FUNC/outa.casl:97:        JZE     RNEXT           ; ↓
138 ../../../../as/FUNC/outa.casl:98:        LD      GR4,GR1         ; GR4にGR1の値をコピー
139 ../../../../as/FUNC/outa.casl:99:        ADDL    GR4,GR3         ; GR4 <- GR4 + GR3
140 ../../../../as/FUNC/outa.casl:100:        LD      GR5,0,GR4       ; GR5にアドレスGR4の値を格納
141 ../../../../as/FUNC/outa.casl:101:        PUSH    0,GR5           ; GR5をプッシュ
142 ../../../../as/FUNC/outa.casl:102:        LAD     GR3,1,GR3       ; GR3 <- GR3 + 1
143 ../../../../as/FUNC/outa.casl:103:        JUMP    RPU             ; ループ終端
144 ../../../../as/FUNC/outa.casl:104:RNEXT   LAD     GR3,0           ; GR3の初期化
145 ../../../../as/FUNC/outa.casl:105:RPO     CPL     GR3,GR2         ; ループ先頭。(GR3 = GR2)の場合、ループ脱出
146 ../../../../as/FUNC/outa.casl:106:        JZE     RFIN            ; ↓
147 ../../../../as/FUNC/outa.casl:107:        POP     GR5             ; GR5にポップ
148 ../../../../as/FUNC/outa.casl:108:        LD      GR4,GR1         ; GR4にGR1の値をコピー
149 ../../../../as/FUNC/outa.casl:109:        ADDL    GR4,GR3         ; GR4 <- GR4 + GR3
150 ../../../../as/FUNC/outa.casl:110:        ST      GR5,0,GR4       ; アドレスGR4にGR5の値を格納
151 ../../../../as/FUNC/outa.casl:111:        LAD     GR3,1,GR3       ; GR3 <- GR3 + 1
152 ../../../../as/FUNC/outa.casl:112:        JUMP    RPO             ; ループ終端
153 ../../../../as/FUNC/outa.casl:113:RFIN    RPOP
154 ../../../../as/FUNC/outa.casl:114:        RET
155 ../../../../as/FUNC/outa.casl:115:        END
156 ../../../../as/FUNC/outa.casl:116:;; GR1の値を絶対値に変換する。GR1にはマイナスの数値が格納されていると想定。
157 ../../../../as/FUNC/outa.casl:117:;; 例: -10 -> 10, -20 -> 20
158 ../../../../as/FUNC/outa.casl:118:OABS    START
159 ../../../../as/FUNC/outa.casl:119:        XOR     GR1,=#FFFF      ; GR1の値を反転
160 ../../../../as/FUNC/outa.casl:120:        LAD     GR1,1,GR1       ; GR1 <- GR1 + 1
161 ../../../../as/FUNC/outa.casl:121:        RET
162 ../../../../as/FUNC/outa.casl:122:        END
163
164 Label::::
165 OUTA.STI ---> #0044
166 ODIVL.ODYOV ---> #00E3
167 STSTR ---> #00B8
168 OUTA.STR ---> #0082
169 COUNT1 ---> #0012
170 ODIVL.ODY ---> #0101
171 COUNT1.RETURN ---> #0021
172 MAIN.MAX ---> #0011
173 REV.RNEXT ---> #011F
174 COUNT1.MORE ---> #001A
175 REV.RFIN ---> #012D
176 REV ---> #0102
177 OUTA.PRT ---> #0062
178 OABS ---> #0135
179 OUTA.NCHAR ---> #0094
180 MAIN.LOOP ---> #0002
181 OUTA.STLST ---> #0051
182 MAIN ---> #0000
183 ODIVL ---> #00C7
184 REV.RPO ---> #0121
185 OUTA ---> #0025
186 REV.RPU ---> #0112
187 MAIN.FIN ---> #0010
188 ODIVL.ODSL ---> #00D8
189 OUTA.LEN ---> #0093
190 ODIVL.ODFIN ---> #00FC
191 OUTA.ZPRT ---> #005E
192 ODIVL.ODLOOP ---> #00EB
193 ODIVL.ODLPIN ---> #00F8
194
195 Assemble ../../../../as/FUNC/count1_call.casl (1)
196 ../../../../as/FUNC/count1_call.casl:1:;; count1.casl(「アセンブラ言語の仕様」プログラム例)を呼び出し、出力結果を表示
197 ../../../../as/FUNC/count1_call.casl:2:;; 使い方: casl2 count1_call.casl count1.casl outa.casl
198 ../../../../as/FUNC/count1_call.casl:3:MAIN    START
199 ../../../../as/FUNC/count1_call.casl:4:        LAD     GR2,0
200         #0000   #1220
201         #0001   #0000
202 ../../../../as/FUNC/count1_call.casl:5:LOOP    CPA     GR2,MAX         ; ループ開始。GR2がMAXの値になったらループ脱出
203         #0002   #4020
204         #0003   #0011
205 ../../../../as/FUNC/count1_call.casl:6:        JZE     FIN             ; ↓
206         #0004   #6300
207         #0005   #0010
208 ../../../../as/FUNC/count1_call.casl:7:        LD      GR1,GR2         ; GR1にVALの値をロード
209         #0006   #1412
210 ../../../../as/FUNC/count1_call.casl:8:        CALL    COUNT1          ; COUNT1を呼び出す。出力はGR0に格納
211         #0007   #8000
212         #0008   #0012
213 ../../../../as/FUNC/count1_call.casl:9:        LD      GR1,GR0         ; GR1にGR0の値をコピー
214         #0009   #1410
215 ../../../../as/FUNC/count1_call.casl:10:        CALL    OUTA            ; OUTAを呼び出す
216         #000A   #8000
217         #000B   #0025
218 ../../../../as/FUNC/count1_call.casl:11:        LAD     GR2,1,GR2       ; GR2 <= GR2 + 1
219         #000C   #1222
220         #000D   #0001
221 ../../../../as/FUNC/count1_call.casl:12:        JUMP    LOOP            ; ループ終端
222         #000E   #6400
223         #000F   #0002
224 ../../../../as/FUNC/count1_call.casl:13:FIN     RET
225         #0010   #8100
226 ../../../../as/FUNC/count1_call.casl:14:MAX     DC      256
227         #0011   #0100
228 ../../../../as/FUNC/count1_call.casl:15:        END
229
230 Assemble ../../../../as/FUNC/count1.casl (1)
231 ../../../../as/FUNC/count1.casl:1:COUNT1        START
232 ../../../../as/FUNC/count1.casl:2:;       入力    GR1:検索する語
233 ../../../../as/FUNC/count1.casl:3:;       処理    GR1中の'1'のビットの個数を求める
234 ../../../../as/FUNC/count1.casl:4:;       出力    GR0:GR1中の'1'のビットの個数
235 ../../../../as/FUNC/count1.casl:5:      PUSH    0,GR1
236         #0012   #7001
237         #0013   #0000
238 ../../../../as/FUNC/count1.casl:6:    PUSH      0,GR2
239         #0014   #7002
240         #0015   #0000
241 ../../../../as/FUNC/count1.casl:7:    SUBA      GR2,GR2
242         #0016   #2522
243 ../../../../as/FUNC/count1.casl:8:    AND               GR1,GR1
244         #0017   #3411
245 ../../../../as/FUNC/count1.casl:9:    JZE       RETURN
246         #0018   #6300
247         #0019   #0021
248 ../../../../as/FUNC/count1.casl:10:MORE LAD     GR2,1,GR2
249         #001A   #1222
250         #001B   #0001
251 ../../../../as/FUNC/count1.casl:11:     LAD             GR0,-1,GR1
252         #001C   #1201
253         #001D   #FFFF
254 ../../../../as/FUNC/count1.casl:12:    AND              GR1,GR0
255         #001E   #3410
256 ../../../../as/FUNC/count1.casl:13:    JNZ              MORE
257         #001F   #6200
258         #0020   #001A
259 ../../../../as/FUNC/count1.casl:14:RETURN LD    GR0,GR2
260         #0021   #1402
261 ../../../../as/FUNC/count1.casl:15:     POP             GR2
262         #0022   #7120
263 ../../../../as/FUNC/count1.casl:16:    POP              GR1
264         #0023   #7110
265 ../../../../as/FUNC/count1.casl:17:    RET
266         #0024   #8100
267 ../../../../as/FUNC/count1.casl:18:    END
268
269 Assemble ../../../../as/FUNC/outa.casl (1)
270 ../../../../as/FUNC/outa.casl:1:;;; GR1に格納された値を、10進数の整数値(-32768〜32767)として表示
271 ../../../../as/FUNC/outa.casl:2:OUTA    START
272 ../../../../as/FUNC/outa.casl:3:        RPUSH
273         #0025   #7001
274         #0026   #0000
275         #0027   #7002
276         #0028   #0000
277         #0029   #7003
278         #002A   #0000
279         #002B   #7004
280         #002C   #0000
281         #002D   #7005
282         #002E   #0000
283         #002F   #7006
284         #0030   #0000
285         #0031   #7007
286         #0032   #0000
287 ../../../../as/FUNC/outa.casl:4:        LAD     GR2,10          ; GR2に10進数の「10」を格納。
288         #0033   #1220
289         #0034   #000A
290 ../../../../as/FUNC/outa.casl:5:        LAD     GR0,0           ; GR0 <- 0
291         #0035   #1200
292         #0036   #0000
293 ../../../../as/FUNC/outa.casl:6:        LAD     GR4,0           ; 負数フラグ。GR1が負数の場合、GR4は1
294         #0037   #1240
295         #0038   #0000
296 ../../../../as/FUNC/outa.casl:7:        ST      GR0,LEN         ; LENの初期化
297         #0039   #1100
298         #003A   #0093
299 ../../../../as/FUNC/outa.casl:8:        AND     GR1,GR1         ; GR1をテスト
300         #003B   #3411
301 ../../../../as/FUNC/outa.casl:9:        JZE     ZPRT            ; GR1が0の場合、ZPRTにジャンプ
302         #003C   #6300
303         #003D   #005E
304 ../../../../as/FUNC/outa.casl:10:        JPL     STI             ; GR1が正数の場合、STIにジャンプ
305         #003E   #6500
306         #003F   #0044
307 ../../../../as/FUNC/outa.casl:11:        LAD     GR4,1           ; GR1が負数の場合、GR4をオン
308         #0040   #1240
309         #0041   #0001
310 ../../../../as/FUNC/outa.casl:12:        CALL    OABS            ;                  GR1を正数に変換
311         #0042   #8000
312         #0043   #0135
313 ../../../../as/FUNC/outa.casl:13:STI     CPL     GR1,GR2         ; ループ先頭。(GR1 < GR2)の場合は、ループ脱出
314         #0044   #4512
315 ../../../../as/FUNC/outa.casl:14:        JMI     STLST           ; ↓
316         #0045   #6100
317         #0046   #0051
318 ../../../../as/FUNC/outa.casl:15:        CALL    ODIVL           ; GR1とGR2の、商をGR0、剰余をGR3に格納
319         #0047   #8000
320         #0048   #00C7
321 ../../../../as/FUNC/outa.casl:16:        LD      GR1,GR3         ; GR1にGR3をコピー
322         #0049   #1413
323 ../../../../as/FUNC/outa.casl:17:        LD      GR1,NCHAR,GR1   ; GR1を文字に変換
324         #004A   #1011
325         #004B   #0094
326 ../../../../as/FUNC/outa.casl:18:        CALL    STSTR           ; GR1をSTR領域に格納
327         #004C   #8000
328         #004D   #00B8
329 ../../../../as/FUNC/outa.casl:19:        LD      GR1,GR0         ; GR0をGR1にコピー
330         #004E   #1410
331 ../../../../as/FUNC/outa.casl:20:        JUMP    STI             ; ループ終端
332         #004F   #6400
333         #0050   #0044
334 ../../../../as/FUNC/outa.casl:21:STLST   LD      GR1,NCHAR,GR1   ; GR1を文字に変換
335         #0051   #1011
336         #0052   #0094
337 ../../../../as/FUNC/outa.casl:22:        CALL    STSTR           ; GR1をSTR領域に格納
338         #0053   #8000
339         #0054   #00B8
340 ../../../../as/FUNC/outa.casl:23:        AND     GR4,GR4         ; 正数の場合
341         #0055   #3444
342 ../../../../as/FUNC/outa.casl:24:        JZE     PRT             ; ↓
343         #0056   #6300
344         #0057   #0062
345 ../../../../as/FUNC/outa.casl:25:        LD      GR1,='-'        ; 負数の場合、「-」をSTR領域に格納
346         #013A   #002D
347         #0058   #1010
348         #0059   #013A
349 ../../../../as/FUNC/outa.casl:26:        CALL    STSTR           ; ↓
350         #005A   #8000
351         #005B   #00B8
352 ../../../../as/FUNC/outa.casl:27:        JUMP    PRT             ; PRTにジャンプ
353         #005C   #6400
354         #005D   #0062
355 ../../../../as/FUNC/outa.casl:28:ZPRT    LD      GR1,NCHAR       ; 「0」をSTR領域に格納
356         #005E   #1010
357         #005F   #0094
358 ../../../../as/FUNC/outa.casl:29:        CALL    STSTR           ; ↓
359         #0060   #8000
360         #0061   #00B8
361 ../../../../as/FUNC/outa.casl:30:PRT     LD      GR2,LEN         ; GR2にLENの値を格納
362         #0062   #1020
363         #0063   #0093
364 ../../../../as/FUNC/outa.casl:31:        LAD     GR1,STR         ; GR1に文字列のアドレスを格納
365         #0064   #1210
366         #0065   #0082
367 ../../../../as/FUNC/outa.casl:32:        CALL    REV             ; 文字列を逆順に並べ替え
368         #0066   #8000
369         #0067   #0102
370 ../../../../as/FUNC/outa.casl:33:        OUT     STR,LEN         ; 文字列を出力
371         #0068   #7001
372         #0069   #0000
373         #006A   #7002
374         #006B   #0000
375         #006C   #1210
376         #006D   #0082
377         #006E   #1020
378         #006F   #0093
379         #0070   #F000
380         #0071   #0002
381         #0072   #1210
382         #0073   #013B
383         #013B   #000A
384         #0074   #1220
385         #0075   #0001
386         #0076   #F000
387         #0077   #0002
388         #0078   #7120
389         #0079   #7110
390 ../../../../as/FUNC/outa.casl:34:        RPOP
391         #007A   #7170
392         #007B   #7160
393         #007C   #7150
394         #007D   #7140
395         #007E   #7130
396         #007F   #7120
397         #0080   #7110
398 ../../../../as/FUNC/outa.casl:35:        RET
399         #0081   #8100
400 ../../../../as/FUNC/outa.casl:36:STR     DS      17
401         #0082   #0000
402         #0083   #0000
403         #0084   #0000
404         #0085   #0000
405         #0086   #0000
406         #0087   #0000
407         #0088   #0000
408         #0089   #0000
409         #008A   #0000
410         #008B   #0000
411         #008C   #0000
412         #008D   #0000
413         #008E   #0000
414         #008F   #0000
415         #0090   #0000
416         #0091   #0000
417         #0092   #0000
418 ../../../../as/FUNC/outa.casl:37:LEN     DS      1
419         #0093   #0000
420 ../../../../as/FUNC/outa.casl:38:NCHAR   DC      '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
421         #0094   #0030
422         #0095   #0031
423         #0096   #0032
424         #0097   #0033
425         #0098   #0034
426         #0099   #0035
427         #009A   #0036
428         #009B   #0037
429         #009C   #0038
430         #009D   #0039
431         #009E   #0041
432         #009F   #0042
433         #00A0   #0043
434         #00A1   #0044
435         #00A2   #0045
436         #00A3   #0046
437         #00A4   #0047
438         #00A5   #0048
439         #00A6   #0049
440         #00A7   #004A
441         #00A8   #004B
442         #00A9   #004C
443         #00AA   #004D
444         #00AB   #004E
445         #00AC   #004F
446         #00AD   #0050
447         #00AE   #0051
448         #00AF   #0052
449         #00B0   #0053
450         #00B1   #0054
451         #00B2   #0055
452         #00B3   #0056
453         #00B4   #0057
454         #00B5   #0058
455         #00B6   #0059
456         #00B7   #005A
457 ../../../../as/FUNC/outa.casl:39:        END
458 ../../../../as/FUNC/outa.casl:40:;; GR1をSTR領域に格納し、LENをインクリメント
459 ../../../../as/FUNC/outa.casl:41:STSTR   START
460 ../../../../as/FUNC/outa.casl:42:        PUSH    0,GR1
461         #00B8   #7001
462         #00B9   #0000
463 ../../../../as/FUNC/outa.casl:43:        PUSH    0,GR2
464         #00BA   #7002
465         #00BB   #0000
466 ../../../../as/FUNC/outa.casl:44:        LD      GR2,LEN         ; GR2にLENの値をロード
467         #00BC   #1020
468         #00BD   #0093
469 ../../../../as/FUNC/outa.casl:45:        ST      GR1,STR,GR2     ; STR+GR2 <- GR1
470         #00BE   #1112
471         #00BF   #0082
472 ../../../../as/FUNC/outa.casl:46:        LAD     GR2,1,GR2       ; GR2 <- GR2 + 1
473         #00C0   #1222
474         #00C1   #0001
475 ../../../../as/FUNC/outa.casl:47:        ST      GR2,LEN         ; LENにGR2を格納
476         #00C2   #1120
477         #00C3   #0093
478 ../../../../as/FUNC/outa.casl:48:        POP     GR2
479         #00C4   #7120
480 ../../../../as/FUNC/outa.casl:49:        POP     GR1
481         #00C5   #7110
482 ../../../../as/FUNC/outa.casl:50:        RET
483         #00C6   #8100
484 ../../../../as/FUNC/outa.casl:51:        END
485 ../../../../as/FUNC/outa.casl:52:;;; GR1の値とGR2の値の、商をGR0、剰余をGR3に格納する
486 ../../../../as/FUNC/outa.casl:53:;;; 0〜65535の範囲の数値を扱う
487 ../../../../as/FUNC/outa.casl:54:ODIVL   START
488 ../../../../as/FUNC/outa.casl:55:        PUSH    0,GR1
489         #00C7   #7001
490         #00C8   #0000
491 ../../../../as/FUNC/outa.casl:56:        PUSH    0,GR2
492         #00C9   #7002
493         #00CA   #0000
494 ../../../../as/FUNC/outa.casl:57:        PUSH    0,GR4
495         #00CB   #7004
496         #00CC   #0000
497 ../../../../as/FUNC/outa.casl:58:        AND     GR2,GR2         ; GR2が0の場合、ODFINへジャンプ
498         #00CD   #3422
499 ../../../../as/FUNC/outa.casl:59:        JZE     ODFIN           ; ↓
500         #00CE   #6300
501         #00CF   #00FC
502 ../../../../as/FUNC/outa.casl:60:        ST      GR2,ODY         ; ODYにGR2の初期値を保存
503         #00D0   #1120
504         #00D1   #0101
505 ../../../../as/FUNC/outa.casl:61:        LAD     GR0,0           ; GR0の初期化
506         #00D2   #1200
507         #00D3   #0000
508 ../../../../as/FUNC/outa.casl:62:        LAD     GR3,0           ; GR3の初期化
509         #00D4   #1230
510         #00D5   #0000
511 ../../../../as/FUNC/outa.casl:63:        LAD     GR4,1           ; GR4の初期化。対象ビットを表す
512         #00D6   #1240
513         #00D7   #0001
514 ../../../../as/FUNC/outa.casl:64:ODSL    CPL     GR2,GR1         ; ループ先頭。(GR2 > GR1)の場合、ODLOOPへループ脱出
515         #00D8   #4521
516 ../../../../as/FUNC/outa.casl:65:        JPL     ODLOOP          ; ↓
517         #00D9   #6500
518         #00DA   #00EB
519 ../../../../as/FUNC/outa.casl:66:        SLL     GR4,1           ; GR4を1回左シフト
520         #00DB   #5240
521         #00DC   #0001
522 ../../../../as/FUNC/outa.casl:67:        SLL     GR2,1           ; GR2を1回左シフト
523         #00DD   #5220
524         #00DE   #0001
525 ../../../../as/FUNC/outa.casl:68:        JOV     ODYOV           ; オーバーフローの場合は、ODYOVにジャンプ
526         #00DF   #6600
527         #00E0   #00E3
528 ../../../../as/FUNC/outa.casl:69:        JUMP    ODSL            ; ループ終端
529         #00E1   #6400
530         #00E2   #00D8
531 ../../../../as/FUNC/outa.casl:70:ODYOV   SRL     GR2,1
532         #00E3   #5320
533         #00E4   #0001
534 ../../../../as/FUNC/outa.casl:71:        LAD     GR2,#8000,GR2
535         #00E5   #1222
536         #00E6   #8000
537 ../../../../as/FUNC/outa.casl:72:        SRL     GR4,1
538         #00E7   #5340
539         #00E8   #0001
540 ../../../../as/FUNC/outa.casl:73:        JUMP    ODLPIN
541         #00E9   #6400
542         #00EA   #00F8
543 ../../../../as/FUNC/outa.casl:74:ODLOOP  SRL     GR4,1           ; ループ先頭。GR4を1回右シフト
544         #00EB   #5340
545         #00EC   #0001
546 ../../../../as/FUNC/outa.casl:75:        JZE     ODFIN           ; (GR4 = 0)の場合、ループ脱出
547         #00ED   #6300
548         #00EE   #00FC
549 ../../../../as/FUNC/outa.casl:76:        SRL     GR2,1           ; GR2を1回右シフト
550         #00EF   #5320
551         #00F0   #0001
552 ../../../../as/FUNC/outa.casl:77:        CPL     GR1,ODY         ; (GR1 < ODY)の場合、ループ脱出
553         #00F1   #4110
554         #00F2   #0101
555 ../../../../as/FUNC/outa.casl:78:        JMI     ODFIN           ; ↓
556         #00F3   #6100
557         #00F4   #00FC
558 ../../../../as/FUNC/outa.casl:79:        CPL     GR1,GR2         ; (GR1 < GR2)の場合、ループ先頭へジャンプ
559         #00F5   #4512
560 ../../../../as/FUNC/outa.casl:80:        JMI     ODLOOP          ; ↓
561         #00F6   #6100
562         #00F7   #00EB
563 ../../../../as/FUNC/outa.casl:81:ODLPIN  SUBL    GR1,GR2         ; GR1 <- GR1 - GR2
564         #00F8   #2712
565 ../../../../as/FUNC/outa.casl:82:        ADDL    GR0,GR4         ; GR0 <- GR0 + GR4
566         #00F9   #2604
567 ../../../../as/FUNC/outa.casl:83:        JUMP    ODLOOP          ; ループ終端
568         #00FA   #6400
569         #00FB   #00EB
570 ../../../../as/FUNC/outa.casl:84:ODFIN   LD      GR3,GR1
571         #00FC   #1431
572 ../../../../as/FUNC/outa.casl:85:        POP    GR4
573         #00FD   #7140
574 ../../../../as/FUNC/outa.casl:86:        POP     GR2
575         #00FE   #7120
576 ../../../../as/FUNC/outa.casl:87:        POP     GR1
577         #00FF   #7110
578 ../../../../as/FUNC/outa.casl:88:        RET
579         #0100   #8100
580 ../../../../as/FUNC/outa.casl:89:ODY     DS      1        
581         #0101   #0000
582 ../../../../as/FUNC/outa.casl:90:        END
583 ../../../../as/FUNC/outa.casl:91:;; アドレスがGR1、長さがGR2の文字列を逆順に並べ替える
584 ../../../../as/FUNC/outa.casl:92:;; 例: 12345 -> 54321、54321- -> -12345
585 ../../../../as/FUNC/outa.casl:93:REV     START
586 ../../../../as/FUNC/outa.casl:94:        RPUSH
587         #0102   #7001
588         #0103   #0000
589         #0104   #7002
590         #0105   #0000
591         #0106   #7003
592         #0107   #0000
593         #0108   #7004
594         #0109   #0000
595         #010A   #7005
596         #010B   #0000
597         #010C   #7006
598         #010D   #0000
599         #010E   #7007
600         #010F   #0000
601 ../../../../as/FUNC/outa.casl:95:        LAD     GR3,0           ; GR3の初期化
602         #0110   #1230
603         #0111   #0000
604 ../../../../as/FUNC/outa.casl:96:RPU     CPL     GR3,GR2         ; ループ先頭。(GR3 = GR2)の場合、ループ脱出
605         #0112   #4532
606 ../../../../as/FUNC/outa.casl:97:        JZE     RNEXT           ; ↓
607         #0113   #6300
608         #0114   #011F
609 ../../../../as/FUNC/outa.casl:98:        LD      GR4,GR1         ; GR4にGR1の値をコピー
610         #0115   #1441
611 ../../../../as/FUNC/outa.casl:99:        ADDL    GR4,GR3         ; GR4 <- GR4 + GR3
612         #0116   #2643
613 ../../../../as/FUNC/outa.casl:100:        LD      GR5,0,GR4       ; GR5にアドレスGR4の値を格納
614         #0117   #1054
615         #0118   #0000
616 ../../../../as/FUNC/outa.casl:101:        PUSH    0,GR5           ; GR5をプッシュ
617         #0119   #7005
618         #011A   #0000
619 ../../../../as/FUNC/outa.casl:102:        LAD     GR3,1,GR3       ; GR3 <- GR3 + 1
620         #011B   #1233
621         #011C   #0001
622 ../../../../as/FUNC/outa.casl:103:        JUMP    RPU             ; ループ終端
623         #011D   #6400
624         #011E   #0112
625 ../../../../as/FUNC/outa.casl:104:RNEXT   LAD     GR3,0           ; GR3の初期化
626         #011F   #1230
627         #0120   #0000
628 ../../../../as/FUNC/outa.casl:105:RPO     CPL     GR3,GR2         ; ループ先頭。(GR3 = GR2)の場合、ループ脱出
629         #0121   #4532
630 ../../../../as/FUNC/outa.casl:106:        JZE     RFIN            ; ↓
631         #0122   #6300
632         #0123   #012D
633 ../../../../as/FUNC/outa.casl:107:        POP     GR5             ; GR5にポップ
634         #0124   #7150
635 ../../../../as/FUNC/outa.casl:108:        LD      GR4,GR1         ; GR4にGR1の値をコピー
636         #0125   #1441
637 ../../../../as/FUNC/outa.casl:109:        ADDL    GR4,GR3         ; GR4 <- GR4 + GR3
638         #0126   #2643
639 ../../../../as/FUNC/outa.casl:110:        ST      GR5,0,GR4       ; アドレスGR4にGR5の値を格納
640         #0127   #1154
641         #0128   #0000
642 ../../../../as/FUNC/outa.casl:111:        LAD     GR3,1,GR3       ; GR3 <- GR3 + 1
643         #0129   #1233
644         #012A   #0001
645 ../../../../as/FUNC/outa.casl:112:        JUMP    RPO             ; ループ終端
646         #012B   #6400
647         #012C   #0121
648 ../../../../as/FUNC/outa.casl:113:RFIN    RPOP
649         #012D   #7170
650         #012E   #7160
651         #012F   #7150
652         #0130   #7140
653         #0131   #7130
654         #0132   #7120
655         #0133   #7110
656 ../../../../as/FUNC/outa.casl:114:        RET
657         #0134   #8100
658 ../../../../as/FUNC/outa.casl:115:        END
659 ../../../../as/FUNC/outa.casl:116:;; GR1の値を絶対値に変換する。GR1にはマイナスの数値が格納されていると想定。
660 ../../../../as/FUNC/outa.casl:117:;; 例: -10 -> 10, -20 -> 20
661 ../../../../as/FUNC/outa.casl:118:OABS    START
662 ../../../../as/FUNC/outa.casl:119:        XOR     GR1,=#FFFF      ; GR1の値を反転
663         #013C   #FFFF
664         #0135   #3210
665         #0136   #013C
666 ../../../../as/FUNC/outa.casl:120:        LAD     GR1,1,GR1       ; GR1 <- GR1 + 1
667         #0137   #1211
668         #0138   #0001
669 ../../../../as/FUNC/outa.casl:121:        RET
670         #0139   #8100
671 ../../../../as/FUNC/outa.casl:122:        END
672 0
673 1
674 1
675 2
676 1
677 2
678 2
679 3
680 1
681 2
682 2
683 3
684 2
685 3
686 3
687 4
688 1
689 2
690 2
691 3
692 2
693 3
694 3
695 4
696 2
697 3
698 3
699 4
700 3
701 4
702 4
703 5
704 1
705 2
706 2
707 3
708 2
709 3
710 3
711 4
712 2
713 3
714 3
715 4
716 3
717 4
718 4
719 5
720 2
721 3
722 3
723 4
724 3
725 4
726 4
727 5
728 3
729 4
730 4
731 5
732 4
733 5
734 5
735 6
736 1
737 2
738 2
739 3
740 2
741 3
742 3
743 4
744 2
745 3
746 3
747 4
748 3
749 4
750 4
751 5
752 2
753 3
754 3
755 4
756 3
757 4
758 4
759 5
760 3
761 4
762 4
763 5
764 4
765 5
766 5
767 6
768 2
769 3
770 3
771 4
772 3
773 4
774 4
775 5
776 3
777 4
778 4
779 5
780 4
781 5
782 5
783 6
784 3
785 4
786 4
787 5
788 4
789 5
790 5
791 6
792 4
793 5
794 5
795 6
796 5
797 6
798 6
799 7
800 1
801 2
802 2
803 3
804 2
805 3
806 3
807 4
808 2
809 3
810 3
811 4
812 3
813 4
814 4
815 5
816 2
817 3
818 3
819 4
820 3
821 4
822 4
823 5
824 3
825 4
826 4
827 5
828 4
829 5
830 5
831 6
832 2
833 3
834 3
835 4
836 3
837 4
838 4
839 5
840 3
841 4
842 4
843 5
844 4
845 5
846 5
847 6
848 3
849 4
850 4
851 5
852 4
853 5
854 5
855 6
856 4
857 5
858 5
859 6
860 5
861 6
862 6
863 7
864 2
865 3
866 3
867 4
868 3
869 4
870 4
871 5
872 3
873 4
874 4
875 5
876 4
877 5
878 5
879 6
880 3
881 4
882 4
883 5
884 4
885 5
886 5
887 6
888 4
889 5
890 5
891 6
892 5
893 6
894 6
895 7
896 3
897 4
898 4
899 5
900 4
901 5
902 5
903 6
904 4
905 5
906 5
907 6
908 5
909 6
910 6
911 7
912 4
913 5
914 5
915 6
916 5
917 6
918 6
919 7
920 5
921 6
922 6
923 7
924 6
925 7
926 7
927 8