1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
|
-
|
|
!
-
|
|
-
|
|
!
-
|
|
-
|
|
!
-
|
|
!
-
|
|
|
-
|
|
|
|
|
|
|
|
|
!
|
#ifndef __MOD_LLONG__
#define __MOD_LLONG__
#module "mod_llong"
#defcfunc MAKELONGLONG int p1, int p2, local llr
llr = 0.0
lpoke llr, 4, p1
lpoke llr, 0, p2
return llr
#defcfunc LOLONG double p1, local llr
llr = p1
return lpeek( llr, 0 )
#defcfunc HILONG double p1, local llr
llr = p1
return lpeek( llr, 4 )
#defcfunc ltoll int p1, local llr
llr = 0.0
if ( p1 & 0x80000000 ) : lpoke llr, 4, 0xFFFFFFFF
lpoke llr, 0, p1
return llr
#defcfunc lltol double p1, local llr
llr = p1
return (lpeek( llr, 0 ) & 0x7FFFFFFF) | (lpeek( llr, 4 ) & 0x80000000)
#defcfunc rndll local llr
llr = 0.0
r = rnd( 32768 )
lpoke llr, 0, r
r = rnd( 32768 )
lpoke llr, 0, (r << 15) | lpeek( llr, 0 )
r = rnd( 32768 )
lpoke llr, 0, (r << 30) | lpeek( llr, 0 )
lpoke llr, 4, r >> 2
r = rnd( 32768 )
lpoke llr, 4, (r << 13) | lpeek( llr, 4 )
r = rnd( 32768 )
lpoke llr, 4, ((r << 28) | lpeek( llr, 4 )) & 0x7FFFFFFF
return llr
#define global ctype addll( %1, %2 ) operatell( 0, %1, %2 ) #define global ctype subll( %1, %2 ) operatell( 1, %1, %2 ) #define global ctype mulll( %1, %2 ) operatell( 2, %1, %2 ) #define global ctype divll( %1, %2 ) operatell( 3, %1, %2 ) #define global ctype modll( %1, %2 ) operatell( 4, %1, %2 ) #define global ctype andll( %1, %2 ) operatell( 5, %1, %2 ) #define global ctype orll( %1, %2 ) operatell( 6, %1, %2 ) #define global ctype xorll( %1, %2 ) operatell( 7, %1, %2 ) #define global ctype eqll( %1, %2 ) operatell( 8, %1, %2 ) #define global ctype nell( %1, %2 ) operatell( 9, %1, %2 ) #define global ctype gtll( %1, %2 ) operatell( 10, %1, %2 ) #define global ctype ltll( %1, %2 ) operatell( 11, %1, %2 ) #define global ctype gteqll( %1, %2 ) operatell( 12, %1, %2 ) #define global ctype lteqll( %1, %2 ) operatell( 13, %1, %2 ) #define global ctype rrll( %1, %2 ) operatell( 14, %1, %2 ) #define global ctype lrll( %1, %2 ) operatell( 15, %1, %2 ) #define global ctype notll( %1, %2 = 0.0 ) operatell( 16, %1, 0.0 ) #define global ctype minusll( %1, %2 = 0.0 ) operatell( 17, %1, 0.0 )
#defcfunc operatell int p1, double p2, double p3, local ll1, local ll2, local llr
ll1 = p2 : ll2 = p3 : llr = 0.0
switch ( p1 )
case 0 a_c = 0
repeat 4
r = wpeek( ll1, cnt * 2 ) + wpeek( ll2, cnt * 2 ) + a_c
a_c = ((r & 0x00010000) != 0)
wpoke llr, cnt * 2, r
loop
swbreak
case 1 s_b = 0
repeat 4
r = 0x00010000 + wpeek( ll1, cnt * 2 ) - wpeek( ll2, cnt * 2) - s_b
s_b = ((r & 0x00010000) == 0)
wpoke llr, cnt * 2, r
loop
swbreak
case 2 repeat 4
m_i = cnt
m_ll = 0.0
m_c = 0
repeat 4 - m_i
r = wpeek( ll1, cnt * 2 ) * wpeek( ll2, m_i * 2 ) + m_c
m_c = (r >> 16) & 0x0000FFFF
wpoke m_ll, (cnt + m_i) * 2, r
loop
llr = addll( llr, m_ll )
loop
swbreak
case 3 case 4 if ( eqll( ll2, 0 ) ) : dialog "Error\ndivision by 0", 1 : end
d_s1 = ltll( ll1, 0 )
if ( d_s1 ) : ll1 = minusll( ll1 )
d_s2 = ltll( ll2, 0 )
if ( d_s2 ) : ll2 = minusll( ll2 )
d_i = 0
repeat 64
if ( peek( ll2, 7 ) & 0x40 ) : break
ll2 = lrll( ll2, 1 )
d_i++
loop
llu = lrll( ltoll( 1 ), d_i )
repeat d_i + 1
llt = subll( ll1, ll2 )
if ( ltll( llt, 0 ) == 0 ) {
llr = addll( llr, llu )
ll1 = llt
}
ll2 = rrll( ll2, 1 )
llu = rrll( llu, 1 )
loop
if ( d_s1 ^ d_s2 ) : llr = minusll( llr )
if ( p1 == 4 ) : llr = ll1 : if ( d_s1 ) : llr = minusll( llr )
swbreak
case 5 lpoke llr, 4, lpeek( ll1, 4 ) & lpeek( ll2, 4 )
lpoke llr, 0, lpeek( ll1, 0 ) & lpeek( ll2, 0 )
swbreak
case 6 lpoke llr, 4, lpeek( ll1, 4 ) | lpeek( ll2, 4 )
lpoke llr, 0, lpeek( ll1, 0 ) | lpeek( ll2, 0 )
swbreak
case 7 lpoke llr, 4, lpeek( ll1, 4 ) ^ lpeek( ll2, 4 )
lpoke llr, 0, lpeek( ll1, 0 ) ^ lpeek( ll2, 0 )
swbreak
case 8 llr = subll( ll1, ll2 )
if ( llr == 0.0 ) : return 1 : else : return 0
swbreak
case 9 llr = subll( ll1, ll2 )
if ( llr != 0.0 ) : return 1 : else : return 0
swbreak
case 10 llr = subll( ll2, ll1 )
if ( peek( llr, 7 ) & 0x80 ) : return 1 : else : return 0
swbreak
case 11 llr = subll( ll1, ll2 )
if ( peek( llr, 7 ) & 0x80 ) : return 1 : else : return 0
swbreak
case 12 if ( eqll( ll1, ll2 ) ) : return 1
return gtll( ll1, ll2 )
swbreak
case 13 if ( eqll( ll1, ll2 ) ) : return 1
return ltll( ll1, ll2 )
swbreak
case 14 r_c = int( ll2 ) & 0x0000003F
if ( r_c = 0 ) : return ll1
r_h = lpeek( ll1, 4 )
r_l = lpeek( ll1, 0 )
if ( r_c > 31 ) {
if ( ltll( ll1, 0 ) ) : lpoke llr, 4, 0xFFFFFFFF : else : lpoke llr, 4, 0
lpoke llr, 0, (r_h >> (r_c - 32))
} else {
lpoke llr, 4, (r_h >> r_c)
lpoke llr, 0, ((r_l >> r_c) & (0x7FFFFFFF >> (r_c - 1))) | (r_h << (32 - r_c))
}
swbreak
case 15 r_c = int( ll2 ) & 0x0000003F
if ( r_c = 0 ) : return ll1
r_h = lpeek( ll1, 4 )
r_l = lpeek( ll1, 0 )
if ( r_c > 31 ) {
lpoke llr, 4, (r_l << (r_c - 32))
lpoke llr, 0, 0
} else {
lpoke llr, 4, (r_h << r_c) | ((r_l >> (32 - r_c)) & (0x7FFFFFFF >> (31 - r_c)))
lpoke llr, 0, (r_l << r_c)
}
swbreak
case 16 lpoke llr, 4, (lpeek( ll1, 4 ) ^ 0xFFFFFFFF)
lpoke llr, 0, (lpeek( ll1, 0 ) ^ 0xFFFFFFFF)
swbreak
case 17 llr = addll( notll( ll1 ), ltoll( 1 ) )
swbreak
swend
return llr
#defcfunc atoll str p1, local llr
llr = 0.0
tmpstr = p1
i = 0
repeat
switch ( peek( tmpstr, i ) )
case '\t'
case ' '
i++
continue
swbreak
case '+'
case '-'
case '$'
case limit( _switch_val, '0', '9' )
break
swbreak
swend
i = -1
break
loop
if ( i == -1 ) : return llr
sg = 0
switch ( peek( tmpstr, i ) )
case '+'
i++
swbreak
case '-'
sg = 1
i++
swbreak
swend
rd = 10
switch ( peek( tmpstr, i ) )
case '$'
rd = 16
i++
swbreak
case '0'
if ( (peek( tmpstr, i + 1 ) == 'X') | (peek( tmpstr, i + 1 ) == 'x') ) {
rd = 16
i += 2
}
swbreak
swend
j = i
repeat
switch ( peek( tmpstr, j ) )
case limit( _switch_val, '0', '9' )
j++
continue
swbreak
case limit( _switch_val, 'A', 'F' )
case limit( _switch_val, 'a', 'f' )
if ( rd == 16 ) { j++ : continue }
swbreak
swend
break
loop
tmpstr = strmid( tmpstr, i, j - i )
l = strlen( tmpstr )
if ( rd == 16 ) {
if ( l < 16 ) { tmpstr = "0000000000000000" + tmpstr : l += 16 }
lpoke llr, 0, int( "$" + strmid( tmpstr, l - 8, 8 ) )
lpoke llr, 4, int( "$" + strmid( tmpstr, l - 16, 8 ) )
} else {
if ( l < 24 ) { tmpstr = "000000000000000000000000" + tmpstr : l += 24 }
llr = ltoll( int( strmid( tmpstr, l - 8, 8 ) ) )
llt = ltoll( int( strmid( tmpstr, l - 16, 8 ) ) )
llt = mulll( llt, ltoll( 100000000 ) )
llr = addll( llr, llt )
llt = ltoll( int( strmid( tmpstr, l - 24, 8 ) ) )
llt = mulll( llt, ltoll( 100000000 ) )
llt = mulll( llt, ltoll( 100000000 ) )
llr = addll( llr, llt )
}
if ( sg ) : llr = minusll( llr )
return llr
#global
#endif
#if 1
randomize
fs_d = "%+20I64d"
fs_h = "0x%016I64X"
nh = MAKELONGLONG( 0x40000000, 0 )
*main
cls
n1 = MAKELONGLONG( 0x7FFFFFFF, 0xFFFFFFFF )
mes strf( "表現可能な正の最大値 : " + fs_h, n1 ) + strf( " = " +fs_d, n1 )
mes strf( fs_d, atoll( "112233445566778899" ) )
mes strf( fs_h, atoll( "0xFFEEDDCCBBAA9988" ) )
n1 = subll( rndll(), nh )
n2 = subll( rndll(), nh )
mes strf( fs_d, n1 ) + strf( " + " + fs_d, n2 ) + strf( " = " + fs_d, addll( n1, n2 ) )
mes strf( fs_d, n1 ) + strf( " - " + fs_d, n2 ) + strf( " = " + fs_d, subll( n1, n2 ) )
mes strf( fs_d, n1 ) + strf( " * " + fs_d, n2 ) + strf( " = " + fs_d, mulll( n1, n2 ) )
mes strf( fs_d, n1 ) + strf( " / " + fs_d, n2 ) + strf( " = " + fs_d, divll( n1, n2 ) )
mes strf( fs_d, n1 ) + strf( " \\ " + fs_d, n2 ) + strf( " = " + fs_d, modll( n1, n2 ) )
n1 = rrll( subll( rndll(), nh ), 32 )
n2 = rrll( subll( rndll(), nh ), 32 )
mes strf( fs_d, n1 ) + strf( " + " + fs_d, n2 ) + strf( " = " + fs_d, addll( n1, n2 ) )
mes strf( fs_d, n1 ) + strf( " - " + fs_d, n2 ) + strf( " = " + fs_d, subll( n1, n2 ) )
mes strf( fs_d, n1 ) + strf( " * " + fs_d, n2 ) + strf( " = " + fs_d, mulll( n1, n2 ) )
mes strf( fs_d, n1 ) + strf( " / " + fs_d, n2 ) + strf( " = " + fs_d, divll( n1, n2 ) )
mes strf( fs_d, n1 ) + strf( " \\ " + fs_d, n2 ) + strf( " = " + fs_d, modll( n1, n2 ) )
n1 = subll( rndll(), nh )
n2 = subll( rndll(), nh )
mes strf( fs_h, n1 ) + strf( " & " + fs_h, n2 ) + strf( " = " + fs_h, andll( n1, n2 ) )
mes strf( fs_h, n1 ) + strf( " | " + fs_h, n2 ) + strf( " = " + fs_h, orll( n1, n2 ) )
mes strf( fs_h, n1 ) + strf( " ^ " + fs_h, n2 ) + strf( " = " + fs_h, xorll( n1, n2 ) )
n1 = subll( rndll(), nh )
n2 = subll( rndll(), nh )
if ( rnd(3) == 0 ) : n2 = n1
mes strf( fs_d, n1 ) + strf( " == " + fs_d, n2 ) + strf( " = %d" , eqll( n1, n2 ) )
mes strf( fs_d, n1 ) + strf( " != " + fs_d, n2 ) + strf( " = %d" , nell( n1, n2 ) )
mes strf( fs_d, n1 ) + strf( " > " + fs_d, n2 ) + strf( " = %d" , gtll( n1, n2 ) )
mes strf( fs_d, n1 ) + strf( " < " + fs_d, n2 ) + strf( " = %d" , ltll( n1, n2 ) )
mes strf( fs_d, n1 ) + strf( " >= " + fs_d, n2 ) + strf( " = %d" , gteqll( n1, n2 ) )
mes strf( fs_d, n1 ) + strf( " <= " + fs_d, n2 ) + strf( " = %d" , lteqll( n1, n2 ) )
n1 = rndll()
n2 = rnd( 64 )
mes strf( fs_h, n1 ) + strf( " >> %d", n2 ) + strf( " = " + fs_h, rrll( n1, n2 ) )
n1 = rndll()
n2 = rnd( 64 )
mes strf( fs_h, n1 ) + strf( " << %d", n2 ) + strf( " = " + fs_h, lrll( n1, n2 ) )
n1 = rndll()
mes strf( "~" + fs_h, n1 ) + strf( " = " + fs_h, notll( n1 ) )
n1 = rndll()
mes strf( "-(%20I64d)", n1 ) + strf( " = %20I64d", minusll( n1 ) )
pos 576, 0 : button "restart", *main
#endif
|