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