Subversion Repositories Kolibri OS

Rev

Rev 109 | Rev 175 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 109 Rev 153
Line 1... Line 1...
1
;;   Calculator for MenuetOS
1
;;   Calculator for MenuetOS (original version)
2
;;  (c)Ville Turjanmaa
2
;;  (c)Ville Turjanmaa
3
;;   Compile with FASM for Menuet
3
;;   Compile with FASM for Menuet
4
;;  
4
;;   
5
;;   Š «ìªã«ïâ®à 1.1 alpha 
5
;;What's new:
6
;;  (c)Pavel Rymovski aka Heavyiron
6
;;   Calc 1.1
7
;;What's new:1)changed design
7
;;           1)changed design
8
;;           2)new procedure of draw window (10 decimal digits, 23 binary, "+" not displayed now)
8
;;           2)new procedure of draw window (10 decimal digits, 23 binary, "+" not displayed now)
9
;;           3)window with skin
9
;;           3)window with skin
10
;;           4)I had used macroses
10
;;           4)I had used macroses
11
;;   Calc 1.2 alpha
11
;;   Calc 1.2
12
;;           1)added some useful functions, such as arcsin, arccos, arctg, 1/x, x^2
12
;;           1)added some useful functions, such as arcsin, arccos, arctg, 1/x, x^2
13
;;   Calc 1.3
13
;;   Calc 1.31
14
;;           1)optimised program
14
;;           1)optimised program
-
 
15
;;           2)new type of window (you need kernel 114 revision or higher)
-
 
16
;;  Pavel Rymovski (Heavyiron)
Line 15... Line 17...
15
 
17
 
16
use32
18
appname equ 'Calc '
Line -... Line 19...
-
 
19
version equ '1.31'
-
 
20
 
17
							 org    0x0
21
use32
18
 
22
               org    0x0
19
               db    'MENUET01'               ; 8 byte id
23
               db    'MENUET01'               ; 8 byte id
20
               dd     0x01                    ; header version
24
               dd     0x01                    ; header version
21
               dd     START                   ; start of code
25
               dd     START                   ; start of code
22
               dd     I_END                   ; size of image
26
               dd     I_END                   ; size of image
23
               dd     0x1000                  ; memory for app
27
               dd     0x1000                  ; memory for app
Line 24... Line 28...
24
               dd     0x1000                  ; esp
28
               dd     0x1000                  ; esp
Line 25... Line 29...
25
               dd     0x0 , 0x0               ; I_Param , I_Icon
29
               dd     0x0,0x0                 ; I_Param , I_Icon
Line 26... Line 30...
26
 
30
 
27
include 'macros.inc'
31
include 'macros.inc'
Line 28... Line 32...
28
 
32
 
29
START:
33
START:
30
 
34
 
31
red:
35
red:
32
    call draw_window
36
    call draw_window
33
 
37
 
34
still:		
38
still:  
35
    push 10 
39
    push 10 
36
    pop eax 
40
    pop eax 
37
    int 40h 
41
    int 40h 
38
    dec eax 
42
    dec eax 
-
 
43
    jz red
39
    jz red
44
    dec eax 
40
    dec eax 
45
    jz key 
41
    jz key 
46
 
42
 
47
button:
43
button:
48
    mov  al,17      ; ¯®«ãç¨âì ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª­®¯ª¨
-
 
49
    int  0x40
44
    mcall 17 	  ; ¯®«ãç¨âì ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª­®¯ª¨
50
    shr  eax,8
45
    shr  eax,8
51
    jmp  testbut
46
    jmp  testbut
52
 
47
 
53
key:         
48
 key:									
54
    mov  al,2       ; ¯®«ãç¨âì ASCII-ª®¤ ­ ¦ â®© ª« ¢¨è¨
49
    mcall 2         ; ¯®«ãç¨âì ASCII-ª®¤ ­ ¦ â®© ª« ¢¨è¨
55
    int  0x40
50
    shr  eax,8
56
    shr  eax,8
Line 58... Line 64...
58
    mov  esi,butid
64
    mov  esi,butid
59
    add  esi,edi
65
    add  esi,edi
60
    lodsb
66
    lodsb
Line 61... Line 67...
61
     
67
     
62
  testbut:
68
  testbut:
63
  	cmp  eax,1	  ; ª­®¯ª  1 - § ªàë⨥ ¯à®£à ¬¬ë
69
    cmp  eax,1      ; ª­®¯ª  1 - § ªàë⨥ ¯à®£à ¬¬ë
64
    jne  noclose
70
    jne  noclose
-
 
71
    or   eax,-1
Line 65... Line 72...
65
    mcall -1 		
72
    int  0x40 
66
 
73
 
67
  noclose:
74
  noclose:
68
    cmp  eax,2
75
    cmp  eax,2
69
    jne  no_reset
76
    jne  no_reset
Line 70... Line 77...
70
    call clear_all
77
    call clear_all
71
    jmp  still
78
    jmp  still
72
  
79
  
73
  no_reset:
80
  no_reset:
74
    finit
81
    finit
75
    mov    ebx,muuta1	 ; ¥à¥¢®¤ ¢ ä®à¬ â FPU
82
    mov  ebx,muuta1  ; ¥à¥¢®¤ ¢ ä®à¬ â FPU
76
    mov    esi,18
83
    mov  esi,18
77
    call   atof
84
    call atof
78
    fstp   [trans1]
85
    fstp [trans1]
79
    mov    ebx,muuta2
86
    mov  ebx,muuta2
80
    mov    esi,18
87
    mov  esi,18
81
    call   atof
88
    call atof
82
    fst    [trans2]
89
    fst  [trans2]
83
    cmp  eax,33
90
    cmp  eax,33
84
    jne  no_sign
91
    jne  no_sign
Line 105... Line 112...
105
    mov  eax,[display_type]
112
    mov  eax,[display_type]
106
    mov  eax,[multipl+eax*4]
113
    mov  eax,[multipl+eax*4]
107
    mov  [entry_multiplier],eax
114
    mov  [entry_multiplier],eax
108
    call print_display
115
    call print_display
109
    jmp  still
116
    jmp  still
110
  multipl:  dd	10,16,2
117
  multipl:  dd 10,16,2
Line 111... Line 118...
111
 
118
 
112
  no_display_change:
119
  no_display_change:
113
    cmp  eax,6
120
    cmp  eax,6
114
    jb	 no_a_f
121
    jb   no_a_f
115
    cmp  eax,11
122
    cmp  eax,11
116
    jg	 no_a_f
123
    jg   no_a_f
117
    add  eax,4
124
    add  eax,4
118
    call number_entry
125
    call number_entry
Line 119... Line 126...
119
    jmp  still
126
    jmp  still
120
   
127
   
121
   no_a_f:
128
   no_a_f:
122
    cmp  eax,12
129
    cmp  eax,12
123
    jb	 no_13
130
    jb   no_13
124
    cmp  eax,14
131
    cmp  eax,14
125
    jg	 no_13
132
    jg   no_13
126
    sub  eax,11
133
    sub  eax,11
Line 127... Line 134...
127
    call number_entry
134
    call number_entry
128
    jmp  still
135
    jmp  still
129
   
136
   
130
   no_13:
137
   no_13:
131
    cmp  eax,19
138
    cmp  eax,19
132
    jb	 no_46
139
    jb   no_46
133
    cmp  eax,21
140
    cmp  eax,21
134
    jg	 no_46
141
    jg   no_46
Line 135... Line 142...
135
    sub  eax,15
142
    sub  eax,15
136
    call number_entry
143
    call number_entry
137
    jmp  still
144
    jmp  still
138
   
145
   
139
   no_46:
146
   no_46:
140
    cmp  eax,26
147
    cmp  eax,26
141
    jb	 no_79
148
    jb   no_79
142
    cmp  eax,28
149
    cmp  eax,28
Line 143... Line 150...
143
    jg	 no_79
150
    jg   no_79
144
    sub  eax,19
151
    sub  eax,19
145
    call number_entry
152
    call number_entry
146
    jmp  still
153
    jmp  still
147
   
154
   
148
   no_79:
155
   no_79:
Line 149... Line 156...
149
    cmp  eax,34
156
    cmp  eax,34
150
    jne  no_0
157
    jne  no_0
Line 301... Line 308...
301
    jmp  still
308
    jmp  still
Line 302... Line 309...
302
 
309
 
303
calculate:
310
calculate:
304
    pusha
311
    pusha
305
    cmp  [calc],' '
312
    cmp  [calc],' '
306
    je	 no_calculation
313
    je   no_calculation
307
    cmp  [calc],'/'
314
    cmp  [calc],'/'
308
    jne  no_cdiv
315
    jne  no_cdiv
Line 309... Line 316...
309
    fdiv [trans1]
316
    fdiv [trans1]
Line 336... Line 343...
336
    pusha
343
    pusha
Line 337... Line 344...
337
 
344
 
338
    cmp  eax,[entry_multiplier]
345
    cmp  eax,[entry_multiplier]
339
    jge  no_entry
346
    jge  no_entry
340
    cmp  [id],1
347
    cmp  [id],1
341
    je	 decimal_entry
348
    je   decimal_entry
342
    mov  ebx,[integer]
349
    mov  ebx,[integer]
343
    test ebx,0xc0000000
350
    test ebx,0xc0000000
344
    jnz  no_entry
351
    jnz  no_entry
345
    mov  ebx,eax
352
    mov  ebx,eax
Line 382... Line 389...
382
    mov  edi,muuta1
389
    mov  edi,muuta1
383
    mov  ecx,18
390
    mov  ecx,18
384
    cld
391
    cld
385
    rep  movsb
392
    rep  movsb
386
    mov  [muuta1],al
393
    mov  [muuta1],al
387
    mov  edi,muuta1+10	    ; 楫®¥
394
    mov  edi,muuta1+10     ; 楫®¥
388
    mov  eax,[integer]
395
    mov  eax,[integer]
Line 389... Line 396...
389
  
396
  
Line 390... Line 397...
390
  new_to_muuta1:
397
  new_to_muuta1:
Line 395... Line 402...
395
    mov  [edi],dl
402
    mov  [edi],dl
396
    add  [edi],byte 48
403
    add  [edi],byte 48
397
    dec  edi
404
    dec  edi
398
    cmp  edi,muuta1+1
405
    cmp  edi,muuta1+1
399
    jge  new_to_muuta1
406
    jge  new_to_muuta1
400
    mov  edi,muuta1+17	    ; ¤à®¡­®¥
407
    mov  edi,muuta1+17     ; ¤à®¡­®¥
401
    mov  eax,[decimal]
408
    mov  eax,[decimal]
Line 402... Line 409...
402
  
409
  
Line 403... Line 410...
403
  new_to_muuta2:
410
  new_to_muuta2:
Line 432... Line 439...
432
    mov  [new_dec],100000
439
    mov  [new_dec],100000
433
    mov  [sign],byte '+'
440
    mov  [sign],byte '+'
434
    popa
441
    popa
435
    ret
442
    ret
Line 436... Line 443...
436
 
443
 
437
ten	   dd	 10.0,0
444
ten          dd  10.0,0
438
tmp	   dw	    1,0
445
tmp          dw  1,0
439
sign	   db	    1,0
446
sign         db  1,0
440
tmp2	   dq	  0x0,0
447
tmp2         dq  0x0,0
441
exp	   dd	  0x0,0
448
exp          dd  0x0,0
442
new_dec    dd  100000,0
449
new_dec      dd  100000,0
443
id	   db	  0x0,0
450
id           db  0x0,0
444
res	dd   0
451
res          dd  0
445
trans1	dq   0
452
trans1       dq  0
446
trans2	dq   0
453
trans2       dq  0
Line 447... Line 454...
447
controlWord dw 1
454
controlWord  dw  1
448
 
455
 
449
ftoa:                         ; fpu st0 -> [integer],[decimal]
456
ftoa:                         ; fpu st0 -> [integer],[decimal]
450
    pusha
457
    pusha
451
    fst    [tmp2]
458
    fst    [tmp2]
452
    fstcw  [controlWord]      ; set truncate integer mode
459
    fstcw  [controlWord]      ; set truncate integer mode
453
    mov    ax,[controlWord]
460
    mov    ax,[controlWord]
454
    mov    [tmp], ax
461
    mov    [tmp], ax
455
    or	   [tmp], word 0x0c00
462
    or     [tmp], word 0x0c00
456
    fldcw  [tmp]
463
    fldcw  [tmp]
457
    ftst                      ; test if st0 is negative
464
    ftst                      ; test if st0 is negative
458
    fstsw  ax
465
    fstsw  ax
Line 465... Line 472...
465
  no_neg:
472
  no_neg:
466
    fistp  [integer]
473
    fistp  [integer]
467
    fld    [tmp2]
474
    fld    [tmp2]
468
    fisub  [integer]
475
    fisub  [integer]
469
    fldcw  [controlWord]
476
    fldcw  [controlWord]
470
    cmp  byte [sign], 0     ; change fraction to positive
477
    cmp    byte [sign], 0     ; change fraction to positive
471
    je	 no_neg2
478
    je     no_neg2
472
    fchs
479
    fchs
Line 473... Line 480...
473
 
480
 
474
  no_neg2:
481
  no_neg2:
475
    mov    [res],0	    ; convert 6 decimal numbers
482
    mov    [res],0     ; convert 6 decimal numbers
Line 476... Line 483...
476
    mov    edi,6
483
    mov    edi,6
477
 
484
 
478
   newd:
485
   newd:
Line 486... Line 493...
486
    fisub  [decimal]
493
    fisub  [decimal]
487
    ftst
494
    ftst
488
    fstsw  ax
495
    fstsw  ax
Line 489... Line 496...
489
    
496
    
490
    dec    edi
497
    dec    edi
491
    jz	   real_done
498
    jz     real_done
Line 492... Line 499...
492
    jmp    newd
499
    jmp    newd
493
 
500
 
494
  real_done:
501
  real_done:
Line 499... Line 506...
499
    call   clear_all
506
    call   clear_all
500
    mov    [calc],'E'
507
    mov    [calc],'E'
Line 501... Line 508...
501
  
508
  
502
  no_error:
509
  no_error:
503
    mov    [dsign],byte '+'
510
    mov    [dsign],byte '+'
504
    cmp    [sign],byte 0	     ; convert negative result
511
    cmp    [sign],byte 0      ; convert negative result
505
    je	   no_negative
512
    je     no_negative
506
    mov    eax,[integer]
513
    mov    eax,[integer]
507
    not    eax
514
    not    eax
508
    inc    eax
515
    inc    eax
509
    mov    [integer],eax
516
    mov    [integer],eax
Line 519... Line 526...
519
    push ax
526
    push ax
520
    push di
527
    push di
521
    fldz
528
    fldz
522
    mov di, 0
529
    mov di, 0
523
    cmp si, 0
530
    cmp si, 0
524
    je .error				; Jump if string has 0 length.
531
    je .error            ; Jump if string has 0 length.
525
    mov byte [sign], 0
532
    mov byte [sign], 0
526
    cmp byte [bx], '+'	 		; Take care of leading '+' or '-'.
533
    cmp byte [bx], '+'   ; Take care of leading '+' or '-'.
527
    jne .noPlus
534
    jne .noPlus
528
    inc di
535
    inc di
529
    jmp .noMinus
536
    jmp .noMinus
Line 530... Line 537...
530
  
537
  
531
  .noPlus:
538
  .noPlus:
532
    cmp byte [bx], '-'
539
    cmp byte [bx], '-'
533
    jne .noMinus
540
    jne .noMinus
534
    mov byte [sign], 1	            ; Number is negative.
541
    mov byte [sign], 1   ; Number is negative.
Line 535... Line 542...
535
    inc di
542
    inc di
536
  
543
  
537
  .noMinus:
544
  .noMinus:
538
    cmp si, di
545
    cmp si, di
539
    je .error
546
    je .error
540
    call atof_convertWholePart
547
    call atof_convertWholePart
541
    jc .error
548
    jc .error
542
    call atof_convertFractionalPart
549
    call atof_convertFractionalPart
543
    jc .error
550
    jc .error
544
    cmp byte [sign], 0
551
    cmp byte [sign], 0
Line 545... Line 552...
545
    je	.dontNegate
552
    je .dontNegate
546
    fchs	   ; Negate value
553
    fchs    ; Negate value
547
 
554
 
Line 548... Line 555...
548
  .dontNegate:
555
  .dontNegate:
549
    mov bh, 0	   ; Set bh to indicate the string is a valid number.
556
    mov bh, 0    ; Set bh to indicate the string is a valid number.
550
    jmp .exit
557
    jmp .exit
Line 551... Line 558...
551
 
558
 
552
  .error:
559
  .error:
553
    mov bh, 1	   ; Set error code.
560
    mov bh, 1    ; Set error code.
554
    fstp st0	   ; Pop top of fpu stack.
561
    fstp st0    ; Pop top of fpu stack.
Line 566... Line 573...
566
 
573
 
567
.mainLoop:
574
.mainLoop:
568
    mov al, [bx + di]
575
    mov al, [bx + di]
569
    cmp al, '.'
576
    cmp al, '.'
570
    je .exit
577
    je .exit
571
    cmp al, '0'    ; Make sure character is a digit.
578
    cmp al, '0'       ; Make sure character is a digit.
572
    jb .error
579
    jb .error
573
    cmp al, '9'
580
    cmp al, '9'
Line 574... Line 581...
574
    ja .error
581
    ja .error
Line 583... Line 590...
583
    ; Multiply current value by 10 and add in digit.
590
    ; Multiply current value by 10 and add in digit.
Line 584... Line 591...
584
 
591
 
585
    fmul dword [ten]
592
    fmul dword [ten]
586
    fiadd word [tmp]
593
    fiadd word [tmp]
587
    inc di
594
    inc di
588
    cmp si, di	   ; Jump if end of string has been reached.
595
    cmp si, di         ; Jump if end of string has been reached.
589
    je .exit
596
    je .exit
Line 590... Line 597...
590
    jmp .mainLoop
597
    jmp .mainLoop
591
 
598
 
592
  .error:
599
  .error:
Line 593... Line 600...
593
    stc 	   ; Set error (carry) flag.
600
    stc                ; Set error (carry) flag.
594
    ret
601
    ret
595
 
602
 
Line 596... Line 603...
596
  .exit:
603
  .exit:
597
    clc 	   ; Clear error (carry) flag.
604
    clc                ; Clear error (carry) flag.
Line 598... Line 605...
598
    ret
605
    ret
599
 
606
 
600
 
607
 
601
atof_convertFractionalPart:
608
atof_convertFractionalPart:
602
    fld1           ; Load 1 to TOS.  This will be the value of the decimal place.
609
    fld1               ; Load 1 to TOS.  This will be the value of the decimal place.
603
 
610
 
604
  .mainLoop:
611
  .mainLoop:
605
    cmp si, di	   ; Jump if end of string has been reached.
612
    cmp si, di         ; Jump if end of string has been reached.
606
    je .exit
613
    je .exit
607
    inc di	       ; Move past the decimal point.
614
    inc di             ; Move past the decimal point.
608
    cmp si, di	   ; Jump if end of string has been reached.
615
    cmp si, di         ; Jump if end of string has been reached.
609
    je .exit
616
    je .exit
610
    mov al, [bx + di]
617
    mov al, [bx + di]
611
    cmp al, '0'    ; Make sure character is a digit.
618
    cmp al, '0'        ; Make sure character is a digit.
612
    jb .error
619
    jb .error
Line 613... Line 620...
613
    cmp al, '9'
620
    cmp al, '9'
Line 624... Line 631...
624
    fmul  st0, st1
631
    fmul  st0, st1
625
    faddp st2, st0
632
    faddp st2, st0
626
    jmp .mainLoop
633
    jmp .mainLoop
Line 627... Line 634...
627
 
634
 
628
  .error:
635
  .error:
629
    stc 	       ; Set error (carry) flag.
636
    stc           ; Set error (carry) flag.
630
    fstp st0	   ; Pop top of fpu stack.
637
    fstp st0    ; Pop top of fpu stack.
Line 631... Line 638...
631
    ret
638
    ret
632
 
639
 
633
  .exit:
640
  .exit:
634
    clc 	   		 ; Clear error (carry) flag.
641
    clc              ; Clear error (carry) flag.
Line 635... Line 642...
635
    fstp st0	   ; Pop top of fpu stack.
642
    fstp st0    ; Pop top of fpu stack.
636
    ret
643
    ret
637
 
644
 
Line 638... Line 645...
638
;   *********************************************
645
;   *********************************************
-
 
646
;   ******* WINDOW DEFINITIONS AND DRAW *********
-
 
647
;   *********************************************
-
 
648
 
-
 
649
draw_window:
-
 
650
    
-
 
651
    mov  eax,48
Line -... Line 652...
-
 
652
    mov  ebx,3
639
;   ******* Ž…„…‹…ˆ… ˆ Ž’ˆ‘Ž‚Š€ ŽŠ€ ********
653
    mov  ecx,sc
-
 
654
    mov  edx,sizeof.system_colors
-
 
655
    int  0x40
-
 
656
 
-
 
657
    mov  eax,12
640
;   *********************************************
658
    mov  ebx,1
-
 
659
    int  0x40
641
 
660
                                   
-
 
661
    mov  eax,0                     
-
 
662
    mov  ebx,200*65536+255        
Line -... Line 663...
-
 
663
    mov  ecx,200*65536+180
642
draw_window:
664
    mov  edx,[sc.work]
643
 
665
    or   edx,0x33000000
644
    mcall 12,1
666
    mov  edi,header
645
    mcall 0,200*65536+255,200*65536+180,0x03ddeeff   ; äã­ªæ¨ï 0: ®¯à¥¤¥«¨âì ¨ ®âà¨á®¢ âì ®ª­®
667
    int  0x40
646
    mcall 4,8*65536+8,0x10000000,labelt,label_len    ; ‡€ƒŽ‹Ž‚ŽŠ ŽŠ€
668
 
647
 
669
    mov  eax,8
648
    mov  ebx,24*65536+28
670
    mov  ebx,19*65536+28
649
    mov  ecx,70*65536+18
671
    mov  ecx,49*65536+18
650
    mov  edx,6
672
    mov  edx,6
651
    mov  esi,0x0066ee
673
    mov  esi,[sc.work_button]
652
    mov  edi,7
674
    mov  edi,7
653
  newbutton:
675
  newbutton:
654
    dec  edi
676
    dec  edi
655
    jnz  no_new_row
677
    jnz  no_new_row
656
    mov  edi,7
678
    mov  edi,7
657
    mov  ebx,24*65536+25+3
679
    mov  ebx,19*65536+28
658
    add  ecx,20*65536
680
    add  ecx,20*65536
659
  no_new_row:
-
 
660
    mcall 8
-
 
661
    add  ebx,30*65536
-
 
662
    inc  edx
-
 
663
    cmp  edx,39
-
 
664
    jbe  newbutton
-
 
665
		
-
 
666
    mcall 8,225*65536+8,28*65536+8,3                    ; 'dec-bin-hex'
-
 
Line -... Line 681...
-
 
681
  no_new_row:
-
 
682
    int  0x40
-
 
683
    add  ebx,30*65536
-
 
684
    inc  edx
-
 
685
    cmp  edx,39
-
 
686
    jbe  newbutton
-
 
687
  
-
 
688
    mcall  ,199*65536+28,49*65536+18,2                  ; 'C'
667
    mcall 8,204*65536+28,70*65536+18,2,0xcc0000         ; 'C'
689
    mcall  ,220*65536+8,7*65536+8,3                     ; 'dec-bin-hex'
668
	
690
 
669
    mov  ebx,25*65536+75                                ; à®à¨á®¢ª  ¯®¤¯¨á¥© ª­®¯®ª
691
    mov  eax,4
670
    mov  ecx,0xffffff
692
    mov  ebx,27*65536+54
671
    mov  edx,text
693
    mov  ecx,[sc.work_button_text]
672
    mov  esi,34
694
    mov  edx,text
-
 
695
    mov  esi,33
673
  
696
  newline:
-
 
697
    int  0x40
-
 
698
    add  ebx,20
674
  newline:
699
    add  edx,33
-
 
700
    cmp  [edx],byte 'x'
-
 
701
    jne  newline
675
    mcall 4
702
    
Line 676... Line 703...
676
    add  ebx,20
703
    call print_display
677
    add  edx,34
704
    
678
    cmp  [edx],byte 'x'
-
 
679
    jne  newline
705
    mov  eax,12
680
    call print_display
-
 
-
 
706
    mov  ebx,2
681
    mcall 12,2
707
    int  0x40
682
    ret
708
 
-
 
709
    ret
-
 
710
 
-
 
711
print_display:
683
 
712
    pusha
-
 
713
    mcall 13,18*65536+210,19*65536+13,0xffffff
-
 
714
 
-
 
715
    mov  eax,4
-
 
716
    mov  ebx,135*65536+7
684
print_display:
717
    mov  ecx,[sc.work_text]
685
    pusha
718
    or   ecx,0x40000000
686
    mcall 13,100*65536+120,25*65536+13,0x00ddeeff
719
    mov  edx,calc
687
    mcall 13,23*65536+210,40*65536+13,0xffffff
720
    mov  esi,1
-
 
721
    mov  edi,[sc.work]
688
    mcall 4,140*65536+28,0,calc,1
722
    int  0x40
689
    mov  eax,4
723
 
690
    mov  ebx,203*65536+29
724
    mov  ebx,198*65536+8
691
    mov  ecx,0
725
    mov  edx,[display_type]
692
    mov  edx,[display_type]
726
    shl  edx,2
-
 
727
    add  edx,display_type_text
-
 
728
    mov  esi,3
-
 
729
    mov  edi,[sc.work]
-
 
730
    int  0x40
693
    shl  edx,2
731
   
694
    add  edx,display_type_text
732
    cmp  [dsign],byte '+'
695
    mov  esi,3
733
    je   positive
696
    int  0x40
734
    mov  ebx,23*65536+22
697
 		
735
    mov  ecx,0x0
698
    cmp  [dsign],byte '+'
736
    mov  edx,dsign
-
 
737
    mov  esi,1
699
    je  positive
738
    int  0x40  
-
 
739
 
-
 
740
positive:  
-
 
741
    cmp  [display_type],0
-
 
742
    jne  no_display_decimal
-
 
743
    cmp  [decimal],0
-
 
744
    je   whole
-
 
745
 
-
 
746
    mov  ebx,180*65536+22
700
    mcall 4,28*65536+43,0x0,dsign,1		
747
    mov  ecx,0x0
-
 
748
    mov  edx,dot
-
 
749
    mov  esi,1
-
 
750
    int  0x40
-
 
751
    
-
 
752
    mov  eax,47
701
	
753
    mov  ebx,10*65536
-
 
754
    mov  ecx,[integer]
-
 
755
    mov  edx,120*65536+22
-
 
756
    mov  esi,0x0
702
positive:		
757
    int  0x40     
703
    cmp  [display_type],0                            ; ¤¥áïâ¨ç­ ï á¨á⥬  áç¨á«¥­¨ï
758
    
Line 704... Line 759...
704
    jne  no_display_decimal
759
    mov  ebx,6*65536
-
 
760
    mov  ecx,[decimal]
-
 
761
    mov  edx,187*65536+22     
-
 
762
    mov  esi,0x0
-
 
763
    int  0x40 
-
 
764
 
-
 
765
    popa
705
    cmp  [decimal],0
766
    ret
706
    je   whole
767
    
-
 
768
whole:
-
 
769
    mov  ebx,220*65536+22
-
 
770
    mov  ecx,0x0
707
    mcall 47,10*65536,[integer],125*65536+43,0x0     ; ®â®¡à ¦ âì 10 æ¨äà
771
    mov  edx,dot
708
    mcall 4,185*65536+43,0x0,dot,1
772
    mov  esi,1
-
 
773
    int  0x40
-
 
774
 
-
 
775
    cmp  [integer],0
709
    mcall 47,6*65536,[decimal],192*65536+43,0x0      ; ®â®¡à ¦ âì 6 æ¨äà ¯®á«¥ § ¯ï⮩
776
    je  null
710
    popa
777
 
711
    ret
778
    mov  eax,47
712
    
779
    mov  ebx,10*65536
713
whole:
-
 
714
    cmp  [integer],0
-
 
715
    je  null
780
    mov  ecx,[integer]
716
    mcall 47,10*65536,[integer],165*65536+43,0x0
781
    mov  edx,160*65536+22
-
 
782
    mov  esi,0x0
-
 
783
    int  0x40
-
 
784
 
-
 
785
    popa
-
 
786
    ret
-
 
787
              
717
    mcall 4,225*65536+43,0x0,dot,1
788
  no_display_decimal:
-
 
789
    cmp  [display_type],1
-
 
790
    jne  no_display_hexadecimal
-
 
791
    cmp  [integer],0
718
    popa
792
    je  null
719
    ret
793
    
Line 720... Line 794...
720
	             
794
    mov  eax,47
721
  no_display_decimal:
795
    mov  ebx,256+8*65536
722
    cmp  [integer],0
796
    mov  ecx,[integer]
-
 
797
    mov  edx,173*65536+22
-
 
798
    mov  esi,0x0
-
 
799
    int  0x40
-
 
800
 
723
    je  null
801
    popa
-
 
802
    ret
724
    cmp  [display_type],1
803
 
725
    jne  no_display_hexadecimal
-
 
-
 
804
  no_display_hexadecimal:
726
    mcall 47,1*256+8*65536,[integer],178*65536+43,0x0    ; ®â®¡à ¦ âì 8 è¥áâ­ ¤æ â¨à¨ç­ëå æ¨äà
805
    cmp  [integer],0
727
    popa
806
    je  null
Line 728... Line 807...
728
    ret
807
 
729
 
808
    mov  eax,47
730
  no_display_hexadecimal:
809
    mov  ebx,2*256+32*65536
731
    cmp  [integer],0
810
    mov  ecx,[integer]
732
    je  null
811
    mov  edx,32*65536+22
-
 
812
    mov  esi,0x0
-
 
813
    int  0x40
733
    cmp  [display_type],2
814
 
734
    jne  null
-
 
735
    mcall 47,2*256+32*65536,[integer],37*65536+43,0x0    ; ®â®¡à ¦ âì 32 ¤¢®¨ç­ë¥ æ¨äàë
815
    popa
736
    popa
816
    ret
Line 737... Line 817...
737
    ret
817
  
738
  
818
  null:
Line 766... Line 846...
766
    call print_display
846
    call print_display
767
    popa
847
    popa
768
    ret
848
    ret
Line -... Line 849...
-
 
849
 
-
 
850
 
769
 
851
;data
Line 770... Line 852...
770
 
852
 
771
;Ž¡« áâì ¤ ­­ëå
853
header db appname,version,0
772
 
-
 
773
display_type       dd  0    ; 0 = decimal, 1 = hexadecimal, 2= binary
-
 
774
entry_multiplier   dd  10
854
 
Line 775... Line 855...
775
 
855
display_type       dd  0    ; 0 = decimal, 1 = hexadecimal, 2= binary
776
display_start_y    dd  0x0
856
entry_multiplier   dd  10
777
display_type_text  db  'dec hex bin'
857
display_type_text  db  'dec hex bin'
778
 
858
 
779
dot	db  '.'
859
dot     db  '.'
Line 780... Line 860...
780
calc	db  ' '
860
calc    db  ' '
781
integer dd    0
861
integer dd    0
782
decimal dd    0
862
decimal dd    0
783
kymppi  dd   10
863
kymppi  dd   10
Line 784... Line 864...
784
 
864
 
785
dsign:
865
dsign:
786
muuta1	db   '+0000000000.000000'
866
muuta1  db   '+0000000000.000000'
787
muuta2	db   '+0000000000.000000'
867
muuta2  db   '+0000000000.000000'
788
muuta0	db   '+0000000000.000000'
868
muuta0  db   '+0000000000.000000'
789
 
869
 
790
text:
870
text:
Line 791... Line 871...
791
    db '  A    B    C    D    E    F    C '
871
    db ' A    B    C    D    E    F    C '
792
    db '  1    2    3    +   Int  Sin Asin'
872
    db ' 1    2    3    +   Int  Sin Asin'
793
    db '  4    5    6    -   1/x  Cos Acos'
-
 
794
    db '  7    8    9    /   x^2  Tan Atan'
-
 
795
    db ' +/-   0    .    *   Sqr  Pi    = '
-
 
796
    db 'x'
-
 
797
 
873
    db ' 4    5    6    -   1/x  Cos Acos'
-
 
874
    db ' 7    8    9    /   x^2  Tan Atan'
-
 
875
    db '+/-   0    .    *   Sqr  Pi    = '
-
 
876
    db 'x'
-
 
877