Subversion Repositories Kolibri OS

Rev

Rev 4935 | Rev 5673 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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