Subversion Repositories Kolibri OS

Rev

Rev 7786 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7786 Rev 8304
1
;;   Calculator for MenuetOS (c) Ville Turjanmaa
1
;;   Calculator for MenuetOS (c) Ville Turjanmaa
2
;;  
2
;;  
3
;;   Compile with FASM
3
;;   Compile with FASM
4
;;   
4
;;   
5
;;   Pavel Rymovski (Heavyiron) - version for KolibriOS
5
;;   Pavel Rymovski (Heavyiron) - version for KolibriOS
6
;;
6
;;
7
;; What's new:
7
;; What's new:
8
;;   Calc 1.1
8
;;   Calc 1.1
9
;;           1) changed design
9
;;           1) changed design
10
;;           2) new procedure of draw window (10 decimal digits, 23 binary, "+" not displayed now)
10
;;           2) new procedure of draw window (10 decimal digits, 23 binary, "+" not displayed now)
11
;;           3) window with skin
11
;;           3) window with skin
12
;;   Calc 1.2
12
;;   Calc 1.2
13
;;           1) added some useful functions, such as arcsin, arccos, arctg, 1/x, x^2
13
;;           1) added some useful functions, such as arcsin, arccos, arctg, 1/x, x^2
14
;;   Calc 1.31
14
;;   Calc 1.31
15
;;           1) optimised program
15
;;           1) optimised program
16
;;           2) new type of window (you need kernel 114 revision or higher)
16
;;           2) new type of window (you need kernel 114 revision or higher)
17
;;   Calc 1.32
17
;;   Calc 1.32
18
;;           1) fixed arccos
18
;;           1) fixed arccos
19
;;   Calc 1.33
19
;;   Calc 1.33
20
;;           1) align button captions in proper way, finally!
20
;;           1) align button captions in proper way, finally!
21
;;   Calc 1.4 - Leency
21
;;   Calc 1.4 - Leency
22
;;           1) better GUI, big fonts
22
;;           1) better GUI, big fonts
23
 
23
 
24
use32
24
use32
25
        org     0x0
25
        org     0x0
26
        db      'MENUET01'      ; 8 byte id
26
        db      'MENUET01'      ; 8 byte id
27
        dd      0x01            ; header version
27
        dd      0x01            ; header version
28
        dd      START           ; start of code
28
        dd      START           ; start of code
29
        dd      I_END           ; size of image
29
        dd      I_END           ; size of image
30
        dd      E_END           ; memory for app
30
        dd      E_END           ; memory for app
31
        dd      E_END           ; esp
31
        dd      E_END           ; esp
32
        dd      0x0,0x0         ; I_Param , I_Icon
32
        dd      0x0,0x0         ; I_Param , I_Icon
33
 
33
 
34
include '../../../macros.inc'
34
include '../../../macros.inc'
35
include '../../../gui_patterns.inc'
35
include '../../../gui_patterns.inc'
36
include '../../../KOSfuncs.inc'
36
include '../../../KOSfuncs.inc'
37
 
37
 
38
hotkeys_count equ 26
38
hotkeys_count equ 26
39
asci:   db 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 43, 61, 13, 45, 42, 47, 44, 46, 27, 182, \
39
asci:   db 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 43, 61, 13, 45, 42, 47, 44, 46, 27, 182, \
40
           97, 98, 99,100,101,102
40
           97, 98, 99,100,101,102
41
butid:  db 12, 13, 14, 19, 20, 21, 26, 27, 28, 34, 15, 39, 39, 22, 36, 29, 35, 35, 1,  2  , \
41
butid:  db 12, 13, 14, 19, 20, 21, 26, 27, 28, 34, 15, 39, 39, 22, 36, 29, 35, 35, 1,  2  , \
42
           6,  7,  8,  9,  10, 11
42
           6,  7,  8,  9,  10, 11
43
 
43
 
44
START:
44
START:
45
red:
45
red:
46
        call    draw_window
46
        call    draw_window
47
still:  
47
still:  
48
        mcall   10
48
        mcall   10
49
 
49
 
50
        dec     eax
50
        dec     eax
51
        jz      red
51
        jz      red
52
        dec     eax 
52
        dec     eax 
53
        jz      key 
53
        jz      key 
54
 
54
 
55
button:
55
button:
56
        mcall   17      ; get button id
56
        mcall   17      ; get button id
57
        shr     eax, 8
57
        shr     eax, 8
58
        jmp     testbut
58
        jmp     testbut
59
 
59
 
60
key:
60
key:
61
        mcall   2       ; get ASCII key code
61
        mcall   2       ; get ASCII key code
62
		and     eax, 0xffff ; supress scancodes
62
		and     eax, 0xffff ; supress scancodes
63
        shr     eax, 8
63
        shr     eax, 8
64
        mov     edi, asci       ; convert ASCII into button id
64
        mov     edi, asci       ; convert ASCII into button id
65
        mov     ecx, hotkeys_count
65
        mov     ecx, hotkeys_count
66
        cld
66
        cld
67
        repne   scasb
67
        repne   scasb
68
        jne     still
68
        jne     still
69
        sub     edi, asci
69
        sub     edi, asci
70
        dec     edi
70
        dec     edi
71
        mov     esi, butid
71
        mov     esi, butid
72
        add     esi, edi
72
        add     esi, edi
73
        lodsb
73
        lodsb
74
 
74
 
75
testbut:
75
testbut:
76
        cmp     eax, 1  ; button 1 -- exit
76
        cmp     eax, 1  ; button 1 -- exit
77
        jne     noexit
77
        jne     noexit
78
        mcall   -1
78
        mcall   -1
79
 
79
 
80
noexit:
80
noexit:
81
        cmp     eax, 2
81
        cmp     eax, 2
82
        jne     no_reset
82
        jne     no_reset
83
        call    clear_all
83
        call    clear_all
84
        jmp     still
84
        jmp     still
85
 
85
 
86
no_reset:
86
no_reset:
87
        finit
87
        finit
88
        mov     ebx, muuta1     ; convert to FPU format
88
        mov     ebx, muuta1     ; convert to FPU format
89
        mov     esi, 18
89
        mov     esi, 18
90
        call    atof
90
        call    atof
91
        fstp    [trans1]
91
        fstp    [trans1]
92
        mov     ebx, muuta2
92
        mov     ebx, muuta2
93
        mov     esi, 18
93
        mov     esi, 18
94
        call    atof
94
        call    atof
95
        fst     [trans2]
95
        fst     [trans2]
96
 
96
 
97
        cmp     eax, 33
97
        cmp     eax, 33
98
        jne     no_sign
98
        jne     no_sign
99
        cmp     [dsign], byte '-'
99
        cmp     [dsign], byte '-'
100
        jne     no_m
100
        jne     no_m
101
        mov     [dsign], byte '+'
101
        mov     [dsign], byte '+'
102
        call    print_display
102
        call    print_display
103
        jmp     still
103
        jmp     still
104
 
104
 
105
no_m:
105
no_m:
106
        mov     [dsign], byte '-'
106
        mov     [dsign], byte '-'
107
        call    print_display
107
        call    print_display
108
        jmp     still
108
        jmp     still
109
 
109
 
110
no_sign:
110
no_sign:
111
        cmp     eax, 3
111
        cmp     eax, 3
112
        jne     no_display_change
112
        jne     no_display_change
113
        inc     [display_type]
113
        inc     [display_type]
114
        cmp     [display_type], 2
114
        cmp     [display_type], 2
115
        jbe     display_continue
115
        jbe     display_continue
116
        mov     [display_type], 0
116
        mov     [display_type], 0
117
 
117
 
118
display_continue:
118
display_continue:
119
        mov     eax, [display_type]
119
        mov     eax, [display_type]
120
        mov     eax, [multipl + eax*4]
120
        mov     eax, [multipl + eax*4]
121
        mov     [entry_multiplier], eax
121
        mov     [entry_multiplier], eax
122
        call    print_display
122
        call    print_display
123
        jmp     still
123
        jmp     still
124
 
124
 
125
no_display_change:
125
no_display_change:
126
        cmp     eax, 6
126
        cmp     eax, 6
127
        jb      no_a_f
127
        jb      no_a_f
128
        cmp     eax, 11
128
        cmp     eax, 11
129
        jg      no_a_f
129
        jg      no_a_f
130
        add     eax, 4
130
        add     eax, 4
131
        call    number_entry
131
        call    number_entry
132
        jmp     still
132
        jmp     still
133
 
133
 
134
no_a_f:
134
no_a_f:
135
        cmp     eax, 12
135
        cmp     eax, 12
136
        jb      no_13
136
        jb      no_13
137
        cmp     eax, 14
137
        cmp     eax, 14
138
        jg      no_13
138
        jg      no_13
139
        sub     eax, 11
139
        sub     eax, 11
140
        call    number_entry
140
        call    number_entry
141
        jmp     still
141
        jmp     still
142
 
142
 
143
no_13:
143
no_13:
144
        cmp     eax, 19
144
        cmp     eax, 19
145
        jb      no_46
145
        jb      no_46
146
        cmp     eax, 21
146
        cmp     eax, 21
147
        jg      no_46
147
        jg      no_46
148
        sub     eax, 15
148
        sub     eax, 15
149
        call    number_entry
149
        call    number_entry
150
        jmp     still
150
        jmp     still
151
 
151
 
152
no_46:
152
no_46:
153
        cmp     eax, 26
153
        cmp     eax, 26
154
        jb      no_79
154
        jb      no_79
155
        cmp     eax, 28
155
        cmp     eax, 28
156
        jg      no_79
156
        jg      no_79
157
        sub     eax, 19
157
        sub     eax, 19
158
        call    number_entry
158
        call    number_entry
159
        jmp     still
159
        jmp     still
160
 
160
 
161
no_79:
161
no_79:
162
        cmp     eax, 34
162
        cmp     eax, 34
163
        jne     no_0
163
        jne     no_0
164
        xor     eax, eax
164
        xor     eax, eax
165
        call    number_entry
165
        call    number_entry
166
        jmp     still
166
        jmp     still
167
 
167
 
168
no_0:
168
no_0:
169
        cmp     eax, 35
169
        cmp     eax, 35
170
        jne     no_id
170
        jne     no_id
171
        inc     [id]
171
        inc     [id]
172
        and     [id], 1
172
        and     [id], 1
173
        mov     [new_dec], 100000
173
        mov     [new_dec], 100000
174
        jmp     still
174
        jmp     still
175
 
175
 
176
no_id:
176
no_id:
177
        cmp     eax, 17
177
        cmp     eax, 17
178
        jne     no_sin
178
        jne     no_sin
179
        fld     [trans1]
179
        fld     [trans1]
180
        fsin
180
        fsin
181
        jmp     show_result
181
        jmp     show_result
182
 
182
 
183
no_sin:
183
no_sin:
184
        cmp     eax, 18
184
        cmp     eax, 18
185
        jne     no_asin
185
        jne     no_asin
186
        fld     [trans1]
186
        fld     [trans1]
187
        fld     st0
187
        fld     st0
188
        fmul    st, st1
188
        fmul    st, st1
189
        fld1
189
        fld1
190
        fsubrp  st1, st0
190
        fsubrp  st1, st0
191
        fsqrt
191
        fsqrt
192
        fpatan
192
        fpatan
193
        jmp     show_result
193
        jmp     show_result
194
 
194
 
195
no_asin:
195
no_asin:
196
        cmp     eax, 16
196
        cmp     eax, 16
197
        jne     no_int
197
        jne     no_int
198
        fld     [trans1]
198
        fld     [trans1]
199
        frndint
199
        frndint
200
        jmp     show_result
200
        jmp     show_result
201
 
201
 
202
no_int:
202
no_int:
203
        cmp     eax, 23
203
        cmp     eax, 23
204
        jne     no_1x
204
        jne     no_1x
205
        fld1
205
        fld1
206
        fdiv    [trans1]
206
        fdiv    [trans1]
207
        jmp     show_result
207
        jmp     show_result
208
 
208
 
209
no_1x:  
209
no_1x:  
210
        cmp     eax, 24
210
        cmp     eax, 24
211
        jne     no_cos
211
        jne     no_cos
212
        fld     [trans1]
212
        fld     [trans1]
213
        fcos
213
        fcos
214
        jmp     show_result
214
        jmp     show_result
215
 
215
 
216
no_cos:
216
no_cos:
217
        cmp     eax, 25
217
        cmp     eax, 25
218
        jne     no_acos
218
        jne     no_acos
219
        fld     [trans1]
219
        fld     [trans1]
220
        fld     st0
220
        fld     st0
221
        fmul    st, st1
221
        fmul    st, st1
222
        fld1
222
        fld1
223
        fsubrp  st1, st0
223
        fsubrp  st1, st0
224
        fsqrt
224
        fsqrt
225
        fxch    st1
225
        fxch    st1
226
        fpatan
226
        fpatan
227
        jmp     show_result
227
        jmp     show_result
228
 
228
 
229
no_acos:   
229
no_acos:   
230
        cmp     eax, 30
230
        cmp     eax, 30
231
        jne     no_x2
231
        jne     no_x2
232
        fld     [trans1]
232
        fld     [trans1]
233
        fmul    st, st0
233
        fmul    st, st0
234
        jmp     show_result
234
        jmp     show_result
235
 
235
 
236
no_x2:  
236
no_x2:  
237
        cmp     eax, 31
237
        cmp     eax, 31
238
        jne     no_tan
238
        jne     no_tan
239
        fld     [trans1]
239
        fld     [trans1]
240
        fptan
240
        fptan
241
        fstp    st2
241
        fstp    st2
242
        jmp     show_result
242
        jmp     show_result
243
 
243
 
244
no_tan:
244
no_tan:
245
        cmp     eax, 32
245
        cmp     eax, 32
246
        jne     no_atan
246
        jne     no_atan
247
        fld     [trans1]
247
        fld     [trans1]
248
        fld1
248
        fld1
249
        fpatan
249
        fpatan
250
        jmp     show_result
250
        jmp     show_result
251
 
251
 
252
no_atan:
252
no_atan:
253
        cmp     eax, 38
253
        cmp     eax, 38
254
        jne     no_pi
254
        jne     no_pi
255
        fldpi
255
        fldpi
256
        jmp     show_result
256
        jmp     show_result
257
 
257
 
258
no_pi:
258
no_pi:
259
        cmp     eax, 37
259
        cmp     eax, 37
260
        jne     no_sqrt
260
        jne     no_sqrt
261
        fld     [trans1]
261
        fld     [trans1]
262
        fsqrt
262
        fsqrt
263
        jmp     show_result
263
        jmp     show_result
264
 
264
 
265
no_sqrt:
265
no_sqrt:
266
        cmp     eax, 15
266
        cmp     eax, 15
267
        jne     no_add
267
        jne     no_add
268
        call    calculate
268
        call    calculate
269
        call    new_entry
269
        call    new_entry
270
        mov     [calc], '+'
270
        mov     [calc], '+'
271
		call    print_display
271
		call    print_display
272
        jmp     still
272
        jmp     still
273
 
273
 
274
no_add:
274
no_add:
275
        cmp     eax, 22
275
        cmp     eax, 22
276
        jne     no_sub
276
        jne     no_sub
277
        call    calculate
277
        call    calculate
278
        call    new_entry
278
        call    new_entry
279
        mov     [calc], '-'
279
        mov     [calc], '-'
280
		call    print_display
280
		call    print_display
281
        jmp     still
281
        jmp     still
282
  
282
  
283
no_sub:
283
no_sub:
284
        cmp     eax, 29
284
        cmp     eax, 29
285
        jne     no_div
285
        jne     no_div
286
        call    calculate
286
        call    calculate
287
        call    new_entry
287
        call    new_entry
288
        mov     [calc], '/'
288
        mov     [calc], '/'
289
		call    print_display
289
		call    print_display
290
        jmp     still
290
        jmp     still
291
 
291
 
292
no_div:
292
no_div:
293
        cmp     eax, 36
293
        cmp     eax, 36
294
        jne     no_mul
294
        jne     no_mul
295
        call    calculate
295
        call    calculate
296
        mov     [calc], '*'
296
        mov     [calc], '*'
297
        call    new_entry
297
        call    new_entry
298
		call    print_display
298
		call    print_display
299
        jmp     still
299
        jmp     still
300
 
300
 
301
no_mul:
301
no_mul:
302
        cmp     eax, 39
302
        cmp     eax, 39
303
        jne     no_calc
303
        jne     no_calc
304
        call    calculate
304
        call    calculate
305
        jmp     still
305
        jmp     still
306
 
306
 
307
no_calc:
307
no_calc:
308
        jmp     still
308
        jmp     still
309
 
309
 
310
show_result:
310
show_result:
311
        call    ftoa
311
        call    ftoa
312
        call    print_display
312
        call    print_display
313
        jmp     still
313
        jmp     still
314
 
314
 
315
error:
315
error:
316
        jmp     still
316
        jmp     still
317
 
317
 
318
calculate:
318
calculate:
319
        pusha
319
        pusha
320
        cmp     [calc], ' '
320
        cmp     [calc], ' '
321
        je      no_calculation
321
        je      no_calculation
322
        cmp     [calc], '/'
322
        cmp     [calc], '/'
323
        jne     no_cdiv
323
        jne     no_cdiv
324
        fdiv    [trans1]
324
        fdiv    [trans1]
325
 
325
 
326
no_cdiv:
326
no_cdiv:
327
        cmp     [calc], '*'
327
        cmp     [calc], '*'
328
        jne     no_cmul
328
        jne     no_cmul
329
        fmul    [trans1]
329
        fmul    [trans1]
330
 
330
 
331
no_cmul:
331
no_cmul:
332
        cmp     [calc], '+'
332
        cmp     [calc], '+'
333
        jne     no_cadd
333
        jne     no_cadd
334
        fadd    [trans1]
334
        fadd    [trans1]
335
 
335
 
336
no_cadd:
336
no_cadd:
337
        cmp     [calc], '-'
337
        cmp     [calc], '-'
338
        jne     no_cdec
338
        jne     no_cdec
339
        fsub    [trans1]
339
        fsub    [trans1]
340
 
340
 
341
no_cdec:
341
no_cdec:
342
        call    ftoa
342
        call    ftoa
343
 
343
 
344
no_calculation:
344
no_calculation:
345
        call    print_display
345
        call    print_display
346
        popa
346
        popa
347
        ret
347
        ret
348
 
348
 
349
number_entry:
349
number_entry:
350
 
350
 
351
        pusha
351
        pusha
352
 
352
 
353
        cmp     eax, [entry_multiplier]
353
        cmp     eax, [entry_multiplier]
354
        jge     no_entry
354
        jge     no_entry
355
        cmp     [id], 1
355
        cmp     [id], 1
356
        je      decimal_entry
356
        je      decimal_entry
357
        mov     ebx, [integer]
357
        mov     ebx, [integer]
358
        test    ebx, 0xf0000000
358
        test    ebx, 0xf0000000
359
        jnz     no_entry
359
        jnz     no_entry
360
        mov     ebx, eax
360
        mov     ebx, eax
361
        mov     eax, [integer]
361
        mov     eax, [integer]
362
        mov     ecx, [entry_multiplier]
362
        mov     ecx, [entry_multiplier]
363
        mul     ecx
363
        mul     ecx
364
        add     eax, ebx
364
        add     eax, ebx
365
        mov     [integer], eax
365
        mov     [integer], eax
366
        call    print_display
366
        call    print_display
367
        call    to_muuta
367
        call    to_muuta
368
        popa
368
        popa
369
        ret
369
        ret
370
 
370
 
371
decimal_entry:
371
decimal_entry:
372
 
372
 
373
        imul    eax, [new_dec]
373
        imul    eax, [new_dec]
374
        add     [decimal], eax
374
        add     [decimal], eax
375
        mov     eax, [new_dec]
375
        mov     eax, [new_dec]
376
        xor     edx, edx
376
        xor     edx, edx
377
        mov     ebx, [entry_multiplier]
377
        mov     ebx, [entry_multiplier]
378
        div     ebx
378
        div     ebx
379
        mov     [new_dec], eax
379
        mov     [new_dec], eax
380
        call    print_display
380
        call    print_display
381
        call    to_muuta
381
        call    to_muuta
382
        popa
382
        popa
383
        ret
383
        ret
384
 
384
 
385
no_entry:
385
no_entry:
386
 
386
 
387
        call    print_display
387
        call    print_display
388
        call    to_muuta
388
        call    to_muuta
389
        popa
389
        popa
390
        ret
390
        ret
391
 
391
 
392
to_muuta:
392
to_muuta:
393
 
393
 
394
        pusha
394
        pusha
395
        mov     al, [dsign]
395
        mov     al, [dsign]
396
        mov     esi, muuta0
396
        mov     esi, muuta0
397
        mov     edi, muuta1
397
        mov     edi, muuta1
398
        mov     ecx, 18
398
        mov     ecx, 18
399
        cld
399
        cld
400
        rep     movsb
400
        rep     movsb
401
        mov     [muuta1], al
401
        mov     [muuta1], al
402
        mov     edi, muuta1+10     ; []
402
        mov     edi, muuta1+10     ; []
403
        mov     eax, [integer]
403
        mov     eax, [integer]
404
 
404
 
405
new_to_muuta1:
405
new_to_muuta1:
406
 
406
 
407
        mov     ebx, 10
407
        mov     ebx, 10
408
        xor     edx, edx
408
        xor     edx, edx
409
        div     ebx
409
        div     ebx
410
        mov     [edi], dl
410
        mov     [edi], dl
411
        add     [edi], byte 48
411
        add     [edi], byte 48
412
        dec     edi
412
        dec     edi
413
        cmp     edi, muuta1+1
413
        cmp     edi, muuta1+1
414
        jge     new_to_muuta1
414
        jge     new_to_muuta1
415
        mov     edi, muuta1+17     ; {}
415
        mov     edi, muuta1+17     ; {}
416
        mov     eax, [decimal]
416
        mov     eax, [decimal]
417
 
417
 
418
new_to_muuta2:
418
new_to_muuta2:
419
 
419
 
420
        mov     ebx, 10
420
        mov     ebx, 10
421
        xor     edx, edx
421
        xor     edx, edx
422
        div     ebx
422
        div     ebx
423
        mov     [edi], dl
423
        mov     [edi], dl
424
        add     [edi], byte 48
424
        add     [edi], byte 48
425
        dec     edi
425
        dec     edi
426
        cmp     edi, muuta1+12
426
        cmp     edi, muuta1+12
427
        jge     new_to_muuta2
427
        jge     new_to_muuta2
428
        popa
428
        popa
429
        ret
429
        ret
430
 
430
 
431
new_entry:
431
new_entry:
432
 
432
 
433
        pusha
433
        pusha
434
        mov     esi, muuta1
434
        mov     esi, muuta1
435
        mov     edi, muuta2
435
        mov     edi, muuta2
436
        mov     ecx, 18
436
        mov     ecx, 18
437
        cld
437
        cld
438
        rep     movsb
438
        rep     movsb
439
        mov     esi, muuta0
439
        mov     esi, muuta0
440
        mov     edi, muuta1
440
        mov     edi, muuta1
441
        mov     ecx, 18
441
        mov     ecx, 18
442
        cld
442
        cld
443
        rep     movsb
443
        rep     movsb
444
        mov     [integer], 0
444
        mov     [integer], 0
445
        mov     [decimal], 0
445
        mov     [decimal], 0
446
        mov     [id], 0
446
        mov     [id], 0
447
        mov     [new_dec], 100000
447
        mov     [new_dec], 100000
448
        mov     [sign], byte '+'
448
        mov     [sign], byte '+'
449
        popa
449
        popa
450
        ret
450
        ret
451
 
451
 
452
 
452
 
453
ftoa:                         ; fpu st0 -> [integer],[decimal]
453
ftoa:                         ; fpu st0 -> [integer],[decimal]
454
        pusha
454
        pusha
455
        fst     [tmp2]
455
        fst     [tmp2]
456
        fstcw   [controlWord]      ; set truncate integer mode
456
        fstcw   [controlWord]      ; set truncate integer mode
457
        mov     ax, [controlWord]
457
        mov     ax, [controlWord]
458
        mov     [tmp], ax
458
        mov     [tmp], ax
459
        or      [tmp], word 0x0c00
459
        or      [tmp], word 0x0c00
460
        fldcw   [tmp]
460
        fldcw   [tmp]
461
        ftst                      ; test if st0 is negative
461
        ftst                      ; test if st0 is negative
462
        fstsw   ax
462
        fstsw   ax
463
        and     ax, 0x4500
463
        and     ax, 0x4500
464
        mov     [sign], 0
464
        mov     [sign], 0
465
        cmp     ax, 0x0100
465
        cmp     ax, 0x0100
466
        jne     no_neg
466
        jne     no_neg
467
        mov     [sign], 1
467
        mov     [sign], 1
468
 
468
 
469
no_neg:
469
no_neg:
470
        fld     [tmp2]
470
        fld     [tmp2]
471
        cmp     byte [sign], 0     ; change fraction to positive
471
        cmp     byte [sign], 0     ; change fraction to positive
472
        je      no_neg2
472
        je      no_neg2
473
        fchs
473
        fchs
474
 
474
 
475
no_neg2:
475
no_neg2:
476
        fadd    [smallValueForRounding]
476
        fadd    [smallValueForRounding]
477
        fist    [integer]
477
        fist    [integer]
478
        fisub   [integer]
478
        fisub   [integer]
479
        mov     [res], 0     ; convert 6 decimal numbers
479
        mov     [res], 0     ; convert 6 decimal numbers
480
        mov     edi, 6
480
        mov     edi, 6
481
 
481
 
482
newd:
482
newd:
483
        fimul   [kymppi]
483
        fimul   [kymppi]
484
        fist    [decimal]
484
        fist    [decimal]
485
        mov     ebx, [res]
485
        mov     ebx, [res]
486
        imul    ebx, 10
486
        imul    ebx, 10
487
        mov     [res], ebx
487
        mov     [res], ebx
488
        mov     eax, [decimal]
488
        mov     eax, [decimal]
489
        add     [res], eax
489
        add     [res], eax
490
        fisub   [decimal]
490
        fisub   [decimal]
491
        fst     [tmp2]
491
        fst     [tmp2]
492
        ftst
492
        ftst
493
        fstsw   ax
493
        fstsw   ax
494
        test    ax, 1
494
        test    ax, 1
495
        jnz     real_done
495
        jnz     real_done
496
        fld     [tmp2]
496
        fld     [tmp2]
497
        dec     edi
497
        dec     edi
498
        jz      real_done
498
        jz      real_done
499
        jmp     newd
499
        jmp     newd
500
 
500
 
501
real_done:
501
real_done:
502
        fldcw   [controlWord]
502
        fldcw   [controlWord]
503
        mov     eax, [res]
503
        mov     eax, [res]
504
        mov     [decimal], eax
504
        mov     [decimal], eax
505
        cmp     [integer], 0x80000000
505
        cmp     [integer], 0x80000000
506
        jne     no_error
506
        jne     no_error
507
        call    clear_all
507
        call    clear_all
508
        mov     [calc], 'E'
508
        mov     [calc], 'E'
509
 
509
 
510
no_error:
510
no_error:
511
        mov     [dsign], byte '+'
511
        mov     [dsign], byte '+'
512
        cmp     [sign], byte 0      ; convert negative result
512
        cmp     [sign], byte 0      ; convert negative result
513
        je      no_negative
513
        je      no_negative
514
;       mov     eax, [integer]
514
;       mov     eax, [integer]
515
;       not     eax
515
;       not     eax
516
;       inc     eax
516
;       inc     eax
517
;       mov     [integer], eax
517
;       mov     [integer], eax
518
        mov     [dsign], byte '-'
518
        mov     [dsign], byte '-'
519
 
519
 
520
no_negative:
520
no_negative:
521
        call    to_muuta
521
        call    to_muuta
522
        popa
522
        popa
523
        ret
523
        ret
524
 
524
 
525
 
525
 
526
atof:
526
atof:
527
        push    ax
527
        push    ax
528
        push    di
528
        push    di
529
        fldz
529
        fldz
530
        mov     di, 0
530
        mov     di, 0
531
        cmp     si, 0
531
        cmp     si, 0
532
        je      .error            ; Jump if string has 0 length.
532
        je      .error            ; Jump if string has 0 length.
533
        mov     byte [sign], 0
533
        mov     byte [sign], 0
534
        cmp     byte [bx], '+'   ; Take care of leading '+' or '-'.
534
        cmp     byte [bx], '+'   ; Take care of leading '+' or '-'.
535
        jne     .noPlus
535
        jne     .noPlus
536
        inc     di
536
        inc     di
537
        jmp     .noMinus
537
        jmp     .noMinus
538
 
538
 
539
  .noPlus:
539
  .noPlus:
540
        cmp     byte [bx], '-'
540
        cmp     byte [bx], '-'
541
        jne     .noMinus
541
        jne     .noMinus
542
        mov     byte [sign], 1   ; Number is negative.
542
        mov     byte [sign], 1   ; Number is negative.
543
        inc     di
543
        inc     di
544
 
544
 
545
  .noMinus:
545
  .noMinus:
546
        cmp     si, di
546
        cmp     si, di
547
        je      .error
547
        je      .error
548
        call    atof_convertWholePart
548
        call    atof_convertWholePart
549
        jc      .error
549
        jc      .error
550
        call    atof_convertFractionalPart
550
        call    atof_convertFractionalPart
551
        jc      .error
551
        jc      .error
552
        cmp     byte [sign], 0
552
        cmp     byte [sign], 0
553
        je      .dontNegate
553
        je      .dontNegate
554
        fchs    ; Negate value
554
        fchs    ; Negate value
555
 
555
 
556
  .dontNegate:
556
  .dontNegate:
557
        mov     bh, 0    ; Set bh to indicate the string is a valid number.
557
        mov     bh, 0    ; Set bh to indicate the string is a valid number.
558
        jmp     .exit
558
        jmp     .exit
559
 
559
 
560
  .error:
560
  .error:
561
        mov     bh, 1    ; Set error code.
561
        mov     bh, 1    ; Set error code.
562
;       fstp    st0    ; Pop top of fpu stack.
562
;       fstp    st0    ; Pop top of fpu stack.
563
 
563
 
564
  .exit:
564
  .exit:
565
        pop     di
565
        pop     di
566
        pop     ax
566
        pop     ax
567
        ret
567
        ret
568
 
568
 
569
atof_convertWholePart:
569
atof_convertWholePart:
570
 
570
 
571
    ; Convert the whole number part (the part preceding the decimal
571
    ; Convert the whole number part (the part preceding the decimal
572
    ; point) by reading a digit at a time, multiplying the current
572
    ; point) by reading a digit at a time, multiplying the current
573
    ; value by 10, and adding the digit.
573
    ; value by 10, and adding the digit.
574
 
574
 
575
  .mainLoop:
575
  .mainLoop:
576
        mov     al, [bx + di]
576
        mov     al, [bx + di]
577
        cmp     al, '.'
577
        cmp     al, '.'
578
        je      .exit
578
        je      .exit
579
        cmp     al, '0'       ; Make sure character is a digit.
579
        cmp     al, '0'       ; Make sure character is a digit.
580
        jb      .error
580
        jb      .error
581
        cmp     al, '9'
581
        cmp     al, '9'
582
        ja      .error
582
        ja      .error
583
 
583
 
584
    ; Convert single character to digit and save to memory for
584
    ; Convert single character to digit and save to memory for
585
    ; transfer to the FPU.
585
    ; transfer to the FPU.
586
 
586
 
587
        sub     al, '0'
587
        sub     al, '0'
588
        mov     ah, 0
588
        mov     ah, 0
589
        mov     [tmp], ax
589
        mov     [tmp], ax
590
 
590
 
591
    ; Multiply current value by 10 and add in digit.
591
    ; Multiply current value by 10 and add in digit.
592
 
592
 
593
        fmul    dword [ten]
593
        fmul    dword [ten]
594
        fiadd   word [tmp]
594
        fiadd   word [tmp]
595
        inc     di
595
        inc     di
596
        cmp     si, di         ; Jump if end of string has been reached.
596
        cmp     si, di         ; Jump if end of string has been reached.
597
        je      .exit
597
        je      .exit
598
        jmp     .mainLoop
598
        jmp     .mainLoop
599
 
599
 
600
  .error:
600
  .error:
601
        stc                ; Set error (carry) flag.
601
        stc                ; Set error (carry) flag.
602
        ret
602
        ret
603
 
603
 
604
  .exit:
604
  .exit:
605
        clc                ; Clear error (carry) flag.
605
        clc                ; Clear error (carry) flag.
606
        ret
606
        ret
607
 
607
 
608
 
608
 
609
atof_convertFractionalPart:
609
atof_convertFractionalPart:
610
        fld1               ; Load 1 to TOS.  This will be the value of the decimal place.
610
        fld1               ; Load 1 to TOS.  This will be the value of the decimal place.
611
 
611
 
612
  .mainLoop:
612
  .mainLoop:
613
        cmp     si, di         ; Jump if end of string has been reached.
613
        cmp     si, di         ; Jump if end of string has been reached.
614
        je      .exit
614
        je      .exit
615
        inc     di             ; Move past the decimal point.
615
        inc     di             ; Move past the decimal point.
616
        cmp     si, di         ; Jump if end of string has been reached.
616
        cmp     si, di         ; Jump if end of string has been reached.
617
        je      .exit
617
        je      .exit
618
        mov     al, [bx + di]
618
        mov     al, [bx + di]
619
        cmp     al, '0'        ; Make sure character is a digit.
619
        cmp     al, '0'        ; Make sure character is a digit.
620
        jb      .error
620
        jb      .error
621
        cmp     al, '9'
621
        cmp     al, '9'
622
        ja      .error
622
        ja      .error
623
        fdiv    dword [ten]   ; Next decimal place
623
        fdiv    dword [ten]   ; Next decimal place
624
        sub     al, '0'
624
        sub     al, '0'
625
        mov     ah, 0
625
        mov     ah, 0
626
        mov     [tmp], ax
626
        mov     [tmp], ax
627
 
627
 
628
    ; Load digit, multiply by value for appropriate decimal place,
628
    ; Load digit, multiply by value for appropriate decimal place,
629
    ; and add to current total.
629
    ; and add to current total.
630
 
630
 
631
        fild    word [tmp]
631
        fild    word [tmp]
632
        fmul    st0, st1
632
        fmul    st0, st1
633
        faddp   st2, st0
633
        faddp   st2, st0
634
        jmp     .mainLoop
634
        jmp     .mainLoop
635
 
635
 
636
  .error:
636
  .error:
637
        stc           ; Set error (carry) flag.
637
        stc           ; Set error (carry) flag.
638
        fstp    st0    ; Pop top of fpu stack.
638
        fstp    st0    ; Pop top of fpu stack.
639
        ret
639
        ret
640
 
640
 
641
  .exit:
641
  .exit:
642
        clc              ; Clear error (carry) flag.
642
        clc              ; Clear error (carry) flag.
643
        fstp    st0    ; Pop top of fpu stack.
643
        fstp    st0    ; Pop top of fpu stack.
644
        ret
644
        ret
645
 
645
 
646
;   *********************************************
646
;   *********************************************
647
;   ******* WINDOW DEFINITIONS AND DRAW *********
647
;   ******* WINDOW DEFINITIONS AND DRAW *********
648
;   *********************************************
648
;   *********************************************
649
 
649
 
650
BTNSP_X equ 39
650
BTNSP_X equ 39
651
DISPLAY_X equ 20
651
DISPLAY_X equ 20
652
DISPLAY_Y equ 18
652
DISPLAY_Y equ 18
653
DISPLAY_W equ 208
653
DISPLAY_W equ 208
654
DISPLAY_H equ 26
654
DISPLAY_H equ 26
655
 
655
 
656
draw_window:
656
draw_window:
657
        mcall   12, 1
657
        mcall   12, 1
658
 
658
 
659
        mcall   48, 3, sc, sizeof.system_colors
659
        mcall   48, 3, sc, sizeof.system_colors
660
 
660
 
661
		mcall SF_STYLE_SETTINGS, SSF_GET_SKIN_HEIGHT
661
		mcall SF_STYLE_SETTINGS, SSF_GET_SKIN_HEIGHT
662
 
662
 
663
		mov     ecx, 200 shl 16 + 210
663
		mov     ecx, 200 shl 16 + 210
664
		add     ecx, eax                ; add skin height to window height 
664
		add     ecx, eax                ; add skin height to window height 
665
        mov     edx, [sc.work]
665
        mov     edx, [sc.work]
666
        or      edx, 0x34000000
666
        or      edx, 0x34000000
667
		mov     edi, title
667
		mov     edi, title
668
        mcall   0, <250, 317>
668
        mcall   0, <250, 317>
669
		
669
		
670
        mov     eax, SF_DEFINE_BUTTON
670
        mov     eax, SF_DEFINE_BUTTON
671
        mov     ebx, 19 shl 16 + 36
671
        mov     ebx, 19 shl 16 + 36
672
        mov     ecx, 55 shl 16 + 22
672
        mov     ecx, 55 shl 16 + 22
673
        mov     edx, 6
673
        mov     edx, 6
674
        mov     esi, [sc.work_button]
674
        mov     esi, [sc.work_button]
675
        mov     edi, 7
675
        mov     edi, 7
676
newbutton:
676
newbutton:
677
        dec     edi
677
        dec     edi
678
        jnz     no_new_row
678
        jnz     no_new_row
679
        mov     edi, 7
679
        mov     edi, 7
680
        mov     ebx, 19 shl 16 + 36
680
        mov     ebx, 19 shl 16 + 36
681
        add     ecx, 28 shl 16
681
        add     ecx, 28 shl 16
682
no_new_row:
682
no_new_row:
683
        mcall
683
        mcall
684
        add     ebx, BTNSP_X shl 16
684
        add     ebx, BTNSP_X shl 16
685
        inc     edx
685
        inc     edx
686
        cmp     edx, BTNSP_X
686
        cmp     edx, BTNSP_X
687
        jbe     newbutton
687
        jbe     newbutton
688
 
688
 
689
        mcall   , <253, 36>, <55, 22>, 2, 0xF0969D  ; 'C'
689
        mcall   , <253, 36>, <55, 22>, 2, 0xF0969D  ; 'C'
690
 
690
 
691
 
691
 
692
        mov     ecx, [sc.work_button_text]
692
        mov     ecx, [sc.work_button_text]
693
		or      ecx, 0x10000000
693
		or      ecx, 0x10000000
694
        mov     edx, text
694
        mov     edx, text
695
        mov     edi, 31
695
        mov     edi, 31
696
next_line:
696
next_line:
697
        inc     edx
697
        inc     edx
698
        and     edi, 0x0000ffff
698
        and     edi, 0x0000ffff
699
        add     edi, 24 SHL 16 + 28
699
        add     edi, 24 SHL 16 + 28
700
next_button:
700
next_button:
701
        movzx   esi, byte[edx - 1]
701
        movzx   esi, byte[edx - 1]
702
        imul    eax, esi, 8
702
        imul    eax, esi, 8
703
        neg     eax
703
        neg     eax
704
        add     eax, 29
704
        add     eax, 29
705
        shr     eax, 1
705
        shr     eax, 1
706
        shl     eax, 16
706
        shl     eax, 16
707
        mov     ebx, edi
707
        mov     ebx, edi
708
        add     ebx, eax
708
        add     ebx, eax
709
        mcall   4
709
        mcall   4
710
        add     edx, esi
710
        add     edx, esi
711
        inc     edx
711
        inc     edx
712
        add     edi, BTNSP_X SHL 16
712
        add     edi, BTNSP_X SHL 16
713
        cmp     [edx - 1], byte 0
713
        cmp     [edx - 1], byte 0
714
		jne     next_button
714
		jne     next_button
715
        cmp     [edx], byte 'x'
715
        cmp     [edx], byte 'x'
716
        jne     next_line
716
        jne     next_line
717
 
717
 
718
		DrawRectangle3D DISPLAY_X-1,DISPLAY_Y-1,DISPLAY_W+2,DISPLAY_H+2, [sc.work_dark], [sc.work_light]
718
		DrawRectangle3D DISPLAY_X-1,DISPLAY_Y-1,DISPLAY_W+2,DISPLAY_H+2, [sc.work_dark], [sc.work_light]
719
		DrawRectangle DISPLAY_X,DISPLAY_Y,DISPLAY_W,DISPLAY_H, [sc.work_graph]
719
		DrawRectangle DISPLAY_X,DISPLAY_Y,DISPLAY_W,DISPLAY_H, [sc.work_graph]
720
        mcall   38, < DISPLAY_X+1, DISPLAY_W+DISPLAY_X-1>, , 0xE0E0E0 ; internal shadow
720
        mcall   38, < DISPLAY_X+1, DISPLAY_W+DISPLAY_X-1>, , 0xE0E0E0 ; internal shadow
721
		mcall     , < DISPLAY_X+1,  DISPLAY_X+1>, ,          ; internal shadow
721
		mcall     , < DISPLAY_X+1,  DISPLAY_X+1>, ,          ; internal shadow
722
		
722
		
723
        call    print_display
723
        call    print_display
724
 
724
 
725
        mcall   12, 2
725
        mcall   12, 2
726
        ret
726
        ret
727
 
727
 
728
print_display:
728
print_display:
729
        pusha
729
        pusha
730
		mcall   13, < DISPLAY_X+2, DISPLAY_W-2>, , 0xFFFfff ; background
730
		mcall   13, < DISPLAY_X+2, DISPLAY_W-2>, , 0xFFFfff ; background
731
		mcall   8, <236,53>, , 3, [sc.work]        ; 'dec-bin-hex'
731
		mcall   8, <236,53>, , 3, [sc.work]        ; 'dec-bin-hex'
732
		
732
		
733
        mov     ecx, [sc.work_text]
733
        mov     ecx, [sc.work_text]
734
        or      ecx, 0x40000000
734
        or      ecx, 0x40000000
735
        mcall   4, <135,6>,,calc,1,[sc.work]
735
        mcall   4, <135,6>,,calc,1,[sc.work]
736
		
736
		
737
        mov     edx, [display_type]
737
        mov     edx, [display_type]
738
        shl     edx, 2
738
        shl     edx, 2
739
        add     edx, display_type_text
739
        add     edx, display_type_text
740
        mov     esi, 3
740
        mov     esi, 3
741
		mov     ecx, [sc.work_text]
741
		mov     ecx, [sc.work_text]
742
		or      ecx, 0x10000000
742
		or      ecx, 0x10000000
743
        mcall   4,<250,DISPLAY_Y+(DISPLAY_H-14)/2>
743
        mcall   4,<250,DISPLAY_Y+(DISPLAY_H-14)/2>
744
 
744
 
745
        cmp     [dsign], byte '+'
745
        cmp     [dsign], byte '+'
746
        je      positive
746
        je      positive
747
        mcall   , <23, 26>, 0, dsign, 1
747
        mcall   , <23, 26>, 0, dsign, 1
748
 
748
 
749
positive:  
749
positive:  
750
        cmp     [display_type], 0
750
        cmp     [display_type], 0
751
        jne     no_display_decimal
751
        jne     no_display_decimal
752
        cmp     [decimal], 0
752
        cmp     [decimal], 0
753
        je      whole
753
        je      whole
754
 
754
 
755
        mcall   , <144, 26>, [number_color], dot, 1
755
        mcall   , <144, 26>, [number_color], dot, 1
756
        mcall   47, <10, 0>, [integer], <26, 26>, [number_color]
756
        mcall   47, <10, 0>, [integer], <26, 26>, [number_color]
757
        mcall   , <6, 0>, [decimal], <151, 26>, [number_color]
757
        mcall   , <6, 0>, [decimal], <151, 26>, [number_color]
758
 
758
 
759
        popa
759
        popa
760
        ret
760
        ret
761
 
761
 
762
whole:
762
whole:
763
        mcall   , <214, 26>, [number_color], dot, 1
763
        mcall   , <214, 26>, [number_color], dot, 1
764
 
764
 
765
        cmp     [integer], 0
765
        cmp     [integer], 0
766
        je      null
766
        je      null
767
        mcall   47, <10, 0>, [integer], <94, 26>, [number_color]
767
        mcall   47, <10, 0>, [integer], <94, 26>, [number_color]
768
        popa
768
        popa
769
        ret
769
        ret
770
 
770
 
771
no_display_decimal:
771
no_display_decimal:
772
        cmp     [display_type], 1
772
        cmp     [display_type], 1
773
        jne     no_display_hexadecimal
773
        jne     no_display_hexadecimal
774
        cmp     [integer], 0
774
        cmp     [integer], 0
775
        je      null
775
        je      null
776
        mcall   47, <8, 256>, [integer], <130, 26>, [number_color]
776
        mcall   47, <8, 256>, [integer], <130, 26>, [number_color]
777
        popa
777
        popa
778
        ret
778
        ret
779
 
779
 
780
no_display_hexadecimal:
780
no_display_hexadecimal:
781
        cmp     [integer], 0
781
        cmp     [integer], 0
782
        je      null
782
        je      null
783
        mcall   47, <32, 2*256>, [integer], <32, 30>, 0
783
        mcall   47, <32, 2*256>, [integer], <32, 30>, 0
784
        popa
784
        popa
785
        ret
785
        ret
786
 
786
 
787
null:
787
null:
788
        mcall   47, <1, 0>, 0, <202, 26>, [number_color]
788
        mcall   47, <1, 0>, 0, <202, 26>, [number_color]
789
        popa
789
        popa
790
        ret
790
        ret
791
 
791
 
792
clear_all:
792
clear_all:
793
        pusha
793
        pusha
794
        mov     [calc], ' '
794
        mov     [calc], ' '
795
        mov     [integer], 0
795
        mov     [integer], 0
796
        mov     [decimal], 0
796
        mov     [decimal], 0
797
        mov     [id], 0
797
        mov     [id], 0
798
        mov     [dsign], byte '+'
798
        mov     [dsign], byte '+'
799
        mov     esi, muuta0
799
        mov     esi, muuta0
800
        mov     edi, muuta1
800
        mov     edi, muuta1
801
        mov     ecx, 18
801
        mov     ecx, 18
802
        cld
802
        cld
803
        rep     movsb
803
        rep     movsb
804
        mov     esi, muuta0
804
        mov     esi, muuta0
805
        mov     edi, muuta2
805
        mov     edi, muuta2
806
        mov     ecx, 18
806
        mov     ecx, 18
807
        cld
807
        cld
808
        rep     movsb
808
        rep     movsb
809
        call    print_display
809
        call    print_display
810
        popa
810
        popa
811
        ret
811
        ret
812
 
812
 
813
 
813
 
814
;data
814
;data
815
 
815
 
816
title   db 'Calc 1.45', 0
816
title   db 'Calc 1.45', 0
817
 
817
 
818
display_type            dd  0    ; 0 = decimal, 1 = hexadecimal, 2= binary
818
display_type            dd  0    ; 0 = decimal, 1 = hexadecimal, 2= binary
819
entry_multiplier        dd  10
819
entry_multiplier        dd  10
820
display_type_text       db  'dec hex bin'
820
display_type_text       db  'dec hex bin'
821
number_color            dd 0x81333333
821
number_color            dd 0x81333333
822
 
822
 
823
dot             db  '.',0
823
dot             db  '.',0
824
calc            db  ' ',0
824
calc            db  ' ',0
825
integer         dd  0
825
integer         dd  0
826
decimal         dd  0
826
decimal         dd  0
827
kymppi          dd  10
827
kymppi          dd  10
828
ten             dd  10.0, 0
828
ten             dd  10.0, 0
829
tmp             dw  1, 0
829
tmp             dw  1, 0
830
sign            db  1, 0
830
sign            db  1, 0
831
tmp2            dq  0, 0
831
tmp2            dq  0, 0
832
exp             dd  0, 0
832
exp             dd  0, 0
833
new_dec         dd  100000, 0
833
new_dec         dd  100000, 0
834
id              db  0, 0
834
id              db  0, 0
835
res             dd  0
835
res             dd  0
836
trans1          dq  0
836
trans1          dq  0
837
trans2          dq  0
837
trans2          dq  0
838
controlWord     dw  1
838
controlWord     dw  1
839
smallValueForRounding dq        0.0000005 ; 1/2 from last significant digit
839
smallValueForRounding dq        0.0000005 ; 1/2 from last significant digit
840
multipl         dd  10,16,2
840
multipl         dd  10,16,2
841
 
841
 
842
dsign:
842
dsign:
843
muuta1          db  '+0000000000.000000'
843
muuta1          db  '+0000000000.000000'
844
muuta2          db  '+0000000000.000000'
844
muuta2          db  '+0000000000.000000'
845
muuta0          db  '+0000000000.000000'
845
muuta0          db  '+0000000000.000000'
846
 
846
 
847
text:
847
text:
848
        db 1,'A',   1,'B', 1,'C', 1,'D', 1,'E',   1,'F',   3,'CLR', 0
848
        db 1,'A',   1,'B', 1,'C', 1,'D', 1,'E',   1,'F',   3,'CLR', 0
849
        db 1,'1',   1,'2', 1,'3', 1,'+', 3,'Int', 3,'Sin', 4,'Asin', 0
849
        db 1,'1',   1,'2', 1,'3', 1,'+', 3,'Int', 3,'Sin', 4,'Asin', 0
850
        db 1,'4',   1,'5', 1,'6', 1,'-', 3,'1/x', 3,'Cos', 4,'Acos', 0
850
        db 1,'4',   1,'5', 1,'6', 1,'-', 3,'1/x', 3,'Cos', 4,'Acos', 0
851
        db 1,'7',   1,'8', 1,'9', 1,'/', 3,'x^2', 3,'Tan', 4,'Atan', 0
851
        db 1,'7',   1,'8', 1,'9', 1,'/', 3,'x^2', 3,'Tan', 4,'Atan', 0
852
        db 3,'+/-', 1,'0', 1,'.', 1,'*', 3,'Sqr', 2,'Pi',  1,'=', 0
852
        db 3,'+/-', 1,'0', 1,'.', 1,'*', 4,'Sqrt',2,'Pi',  1,'=', 0
853
        db 'x'
853
        db 'x'
854
 
854
 
855
I_END:
855
I_END:
856
 
856
 
857
sc      system_colors
857
sc      system_colors
858
rb      0x200	; stack
858
rb      0x200	; stack
859
E_END:
859
E_END: