Subversion Repositories Kolibri OS

Rev

Rev 109 | Rev 175 | Go to most recent revision | Show entire file | Regard 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)
-
 
17
 
-
 
18
appname equ 'Calc '
-
 
19
version equ '1.31'
Line 15... Line 20...
15
 
20
 
16
use32
21
use32
17
							 org    0x0
-
 
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
Line 39... Line 43...
39
    jz red
43
    jz red
40
    dec eax 
44
    dec eax 
41
    jz key 
45
    jz key 
Line 42... Line 46...
42
 
46
 
43
button:
47
button:
-
 
48
    mov  al,17      ; ¯®«ãç¨âì ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª­®¯ª¨
44
    mcall 17 	  ; ¯®«ãç¨âì ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª­®¯ª¨
49
    int  0x40
45
    shr  eax,8
50
    shr  eax,8
Line 46... Line 51...
46
    jmp  testbut
51
    jmp  testbut
47
 
52
 
-
 
53
key:         
48
 key:									
54
    mov  al,2       ; ¯®«ãç¨âì ASCII-ª®¤ ­ ¦ â®© ª« ¢¨è¨
49
    mcall 2         ; ¯®«ãç¨âì ASCII-ª®¤ ­ ¦ â®© ª« ¢¨è¨
55
    int  0x40
50
    shr  eax,8
56
    shr  eax,8
51
    mov  edi,asci	  ; ¯¥à¥¢®¤ ASCII ¢ ¨¤¥­â¨ä¨ª â®à ª­®¯ª¨
57
    mov  edi,asci   ; ¯¥à¥¢®¤ ASCII ¢ ¨¤¥­â¨ä¨ª â®à ª­®¯ª¨
52
    mov  ecx,18
58
    mov  ecx,18
Line 60... Line 66...
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
Line 146... Line 153...
146
    jmp  still
153
    jmp  still
Line 147... Line 154...
147
   
154
   
148
   no_79:
155
   no_79:
149
    cmp  eax,34
156
    cmp  eax,34
150
    jne  no_0
157
    jne  no_0
151
    mov  eax,0
158
    xor  eax,eax
152
    call number_entry
159
    call number_entry
Line 153... Line 160...
153
    jmp  still
160
    jmp  still
154
   
161
   
Line 634... Line 641...
634
    clc 	   		 ; Clear error (carry) flag.
641
    clc              ; Clear error (carry) flag.
635
    fstp st0	   ; Pop top of fpu stack.
642
    fstp st0    ; Pop top of fpu stack.
636
    ret
643
    ret
Line 637... Line 644...
637
 
644
 
638
;   *********************************************
645
;   *********************************************
639
;   ******* Ž…„…‹…ˆ… ˆ Ž’ˆ‘Ž‚Š€ ŽŠ€ ********
646
;   ******* WINDOW DEFINITIONS AND DRAW *********
Line 640... Line 647...
640
;   *********************************************
647
;   *********************************************
Line -... Line 648...
-
 
648
 
641
 
649
draw_window:
642
draw_window:
-
 
-
 
650
    
643
 
651
    mov  eax,48
-
 
652
    mov  ebx,3
-
 
653
    mov  ecx,sc
-
 
654
    mov  edx,sizeof.system_colors
-
 
655
    int  0x40
-
 
656
 
Line -... Line 657...
-
 
657
    mov  eax,12
-
 
658
    mov  ebx,1
-
 
659
    int  0x40
-
 
660
                                   
-
 
661
    mov  eax,0                     
-
 
662
    mov  ebx,200*65536+255        
-
 
663
    mov  ecx,200*65536+180
-
 
664
    mov  edx,[sc.work]
-
 
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:
681
  no_new_row:
660
    mcall 8
682
    int  0x40
Line 661... Line 683...
661
    add  ebx,30*65536
683
    add  ebx,30*65536
662
    inc  edx
684
    inc  edx
Line -... Line 685...
-
 
685
    cmp  edx,39
663
    cmp  edx,39
686
    jbe  newbutton
664
    jbe  newbutton
687
  
665
		
688
    mcall  ,199*65536+28,49*65536+18,2                  ; 'C'
666
    mcall 8,225*65536+8,28*65536+8,3                    ; 'dec-bin-hex'
689
    mcall  ,220*65536+8,7*65536+8,3                     ; 'dec-bin-hex'
667
    mcall 8,204*65536+28,70*65536+18,2,0xcc0000         ; 'C'
-
 
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
673
  
695
    mov  esi,33
-
 
696
  newline:
674
  newline:
697
    int  0x40
-
 
698
    add  ebx,20
-
 
699
    add  edx,33
675
    mcall 4
700
    cmp  [edx],byte 'x'
-
 
701
    jne  newline
-
 
702
    
676
    add  ebx,20
703
    call print_display
Line 677... Line 704...
677
    add  edx,34
704
    
678
    cmp  [edx],byte 'x'
705
    mov  eax,12
679
    jne  newline
-
 
680
    call print_display
706
    mov  ebx,2
681
    mcall 12,2
-
 
-
 
707
    int  0x40
682
    ret
708
 
683
 
709
    ret
-
 
710
 
-
 
711
print_display:
-
 
712
    pusha
684
print_display:
713
    mcall 13,18*65536+210,19*65536+13,0xffffff
-
 
714
 
-
 
715
    mov  eax,4
-
 
716
    mov  ebx,135*65536+7
-
 
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
688
    mcall 4,140*65536+28,0,calc,1
721
    mov  edi,[sc.work]
-
 
722
    int  0x40
689
    mov  eax,4
723
 
Line 690... Line 724...
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
Line 693... Line 731...
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
-
 
736
    mov  edx,dsign
698
    cmp  [dsign],byte '+'
737
    mov  esi,1
-
 
738
    int  0x40  
-
 
739
 
-
 
740
positive:  
-
 
741
    cmp  [display_type],0
-
 
742
    jne  no_display_decimal
-
 
743
    cmp  [decimal],0
-
 
744
    je   whole
-
 
745
 
699
    je  positive
746
    mov  ebx,180*65536+22
-
 
747
    mov  ecx,0x0
-
 
748
    mov  edx,dot
-
 
749
    mov  esi,1
-
 
750
    int  0x40
-
 
751
    
700
    mcall 4,28*65536+43,0x0,dsign,1		
752
    mov  eax,47
-
 
753
    mov  ebx,10*65536
-
 
754
    mov  ecx,[integer]
-
 
755
    mov  edx,120*65536+22
701
	
756
    mov  esi,0x0
702
positive:		
757
    int  0x40     
Line 703... Line 758...
703
    cmp  [display_type],0                            ; ¤¥áïâ¨ç­ ï á¨á⥬  áç¨á«¥­¨ï
758
    
-
 
759
    mov  ebx,6*65536
-
 
760
    mov  ecx,[decimal]
-
 
761
    mov  edx,187*65536+22     
-
 
762
    mov  esi,0x0
-
 
763
    int  0x40 
-
 
764
 
704
    jne  no_display_decimal
765
    popa
705
    cmp  [decimal],0
766
    ret
-
 
767
    
-
 
768
whole:
-
 
769
    mov  ebx,220*65536+22
706
    je   whole
770
    mov  ecx,0x0
707
    mcall 47,10*65536,[integer],125*65536+43,0x0     ; ®â®¡à ¦ âì 10 æ¨äà
771
    mov  edx,dot
-
 
772
    mov  esi,1
-
 
773
    int  0x40
-
 
774
 
708
    mcall 4,185*65536+43,0x0,dot,1
775
    cmp  [integer],0
709
    mcall 47,6*65536,[decimal],192*65536+43,0x0      ; ®â®¡à ¦ âì 6 æ¨äà ¯®á«¥ § ¯ï⮩
776
    je  null
Line 710... Line 777...
710
    popa
777
 
711
    ret
-
 
712
    
-
 
713
whole:
778
    mov  eax,47
714
    cmp  [integer],0
779
    mov  ebx,10*65536
-
 
780
    mov  ecx,[integer]
-
 
781
    mov  edx,160*65536+22
-
 
782
    mov  esi,0x0
-
 
783
    int  0x40
-
 
784
 
-
 
785
    popa
715
    je  null
786
    ret
-
 
787
              
-
 
788
  no_display_decimal:
-
 
789
    cmp  [display_type],1
716
    mcall 47,10*65536,[integer],165*65536+43,0x0
790
    jne  no_display_hexadecimal
717
    mcall 4,225*65536+43,0x0,dot,1
791
    cmp  [integer],0
Line 718... Line 792...
718
    popa
792
    je  null
719
    ret
793
    
720
	             
794
    mov  eax,47
-
 
795
    mov  ebx,256+8*65536
-
 
796
    mov  ecx,[integer]
-
 
797
    mov  edx,173*65536+22
-
 
798
    mov  esi,0x0
721
  no_display_decimal:
799
    int  0x40
-
 
800
 
722
    cmp  [integer],0
801
    popa
723
    je  null
-
 
-
 
802
    ret
724
    cmp  [display_type],1
803
 
725
    jne  no_display_hexadecimal
804
  no_display_hexadecimal:
Line 726... Line 805...
726
    mcall 47,1*256+8*65536,[integer],178*65536+43,0x0    ; ®â®¡à ¦ âì 8 è¥áâ­ ¤æ â¨à¨ç­ëå æ¨äà
805
    cmp  [integer],0
727
    popa
806
    je  null
728
    ret
807
 
729
 
808
    mov  eax,47
730
  no_display_hexadecimal:
809
    mov  ebx,2*256+32*65536
-
 
810
    mov  ecx,[integer]
-
 
811
    mov  edx,32*65536+22
Line 731... Line -...
731
    cmp  [integer],0
-
 
732
    je  null
812
    mov  esi,0x0
733
    cmp  [display_type],2
813
    int  0x40
Line 734... Line 814...
734
    jne  null
814
 
735
    mcall 47,2*256+32*65536,[integer],37*65536+43,0x0    ; ®â®¡à ¦ âì 32 ¤¢®¨ç­ë¥ æ¨äàë
815
    popa
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'
Line 795... Line 875...
795
    db ' +/-   0    .    *   Sqr  Pi    = '
875
    db '+/-   0    .    *   Sqr  Pi    = '
796
    db 'x'
876
    db 'x'
Line 797... Line 877...
797
 
877
 
798
asci:  db 49,50,51,52,53,54,55,56,57,48,43,61,45,42,47,44,46,27
878
asci:  db 49,50,51,52,53,54,55,56,57,48,43,61,45,42,47,44,46,27
799
butid: db 12,13,14,19,20,21,26,27,28,34,15,39,22,36,29,35,35,1
879
butid: db 12,13,14,19,20,21,26,27,28,34,15,39,22,36,29,35,35,1
800
labelt:
-
 
801
      db   'Calc 1.3'
-
 
802
label_len = $ - labelt
880
 
803
I_END:
881
I_END:
-
 
882
 
-
 
883
sc     system_colors