Subversion Repositories Kolibri OS

Rev

Rev 967 | Rev 3625 | 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
107 heavyiron 13
;;           1)added some useful functions, such as arcsin, arccos, arctg, 1/x, x^2
153 heavyiron 14
;;   Calc 1.31
107 heavyiron 15
;;           1)optimised program
153 heavyiron 16
;;           2)new type of window (you need kernel 114 revision or higher)
382 heavyiron 17
;;   Calc 1.32
18
;;           1)fixed arccos
31 halyavin 19
 
382 heavyiron 20
 
153 heavyiron 21
appname equ 'Calc '
382 heavyiron 22
version    equ '1.32'
153 heavyiron 23
 
31 halyavin 24
use32
153 heavyiron 25
               org    0x0
382 heavyiron 26
               db    'MENUET01'            ; 8 byte id
27
               dd     0x01                      ; header version
28
               dd     START                    ; start of code
29
               dd     I_END                    ; size of image
31 halyavin 30
               dd     0x1000                  ; memory for app
31
               dd     0x1000                  ; esp
153 heavyiron 32
               dd     0x0,0x0                 ; I_Param , I_Icon
31 halyavin 33
 
485 heavyiron 34
include '..\..\..\macros.inc'
31 halyavin 35
 
107 heavyiron 36
START:
31 halyavin 37
 
485 heavyiron 38
 red:
107 heavyiron 39
    call draw_window
31 halyavin 40
 
485 heavyiron 41
 still:
107 heavyiron 42
    push 10
43
    pop eax
485 heavyiron 44
    mcall
45
 
46
    dec eax
107 heavyiron 47
    jz red
48
    dec eax
49
    jz key
153 heavyiron 50
 
485 heavyiron 51
  button:
153 heavyiron 52
    mov  al,17      ; получить идентификатор нажатой кнопки
485 heavyiron 53
    mcall
31 halyavin 54
    shr  eax,8
107 heavyiron 55
    jmp  testbut
153 heavyiron 56
 
485 heavyiron 57
  key:
153 heavyiron 58
    mov  al,2       ; получить ASCII-код нажатой клавиши
485 heavyiron 59
    mcall
107 heavyiron 60
    shr  eax,8
153 heavyiron 61
    mov  edi,asci   ; перевод ASCII в идентификатор кнопки
107 heavyiron 62
    mov  ecx,18
31 halyavin 63
    cld
64
    repne scasb
65
    jne  still
66
    sub  edi,asci
67
    dec  edi
68
    mov  esi,butid
69
    add  esi,edi
70
    lodsb
107 heavyiron 71
 
31 halyavin 72
  testbut:
153 heavyiron 73
    cmp  eax,1      ; кнопка 1 - закрытие программы
31 halyavin 74
    jne  noclose
153 heavyiron 75
    or   eax,-1
485 heavyiron 76
    mcall
107 heavyiron 77
 
31 halyavin 78
  noclose:
79
    cmp  eax,2
80
    jne  no_reset
81
    call clear_all
82
    jmp  still
107 heavyiron 83
 
31 halyavin 84
  no_reset:
85
    finit
153 heavyiron 86
    mov  ebx,muuta1  ; Перевод в формат FPU
87
    mov  esi,18
88
    call atof
89
    fstp [trans1]
90
    mov  ebx,muuta2
91
    mov  esi,18
92
    call atof
93
    fst  [trans2]
205 heavyiron 94
 
107 heavyiron 95
    cmp  eax,33
31 halyavin 96
    jne  no_sign
97
    cmp  [dsign],byte '-'
98
    jne  no_m
99
    mov  [dsign],byte '+'
100
    call print_display
101
    jmp  still
107 heavyiron 102
 
31 halyavin 103
  no_m:
104
    mov  [dsign],byte '-'
105
    call print_display
106
    jmp  still
107 heavyiron 107
 
31 halyavin 108
  no_sign:
109
    cmp  eax,3
110
    jne  no_display_change
111
    inc  [display_type]
112
    cmp  [display_type],2
113
    jbe  display_continue
114
    mov  [display_type],0
107 heavyiron 115
 
31 halyavin 116
  display_continue:
117
    mov  eax,[display_type]
118
    mov  eax,[multipl+eax*4]
119
    mov  [entry_multiplier],eax
120
    call print_display
121
    jmp  still
122
 
123
  no_display_change:
124
    cmp  eax,6
153 heavyiron 125
    jb   no_a_f
31 halyavin 126
    cmp  eax,11
153 heavyiron 127
    jg   no_a_f
31 halyavin 128
    add  eax,4
129
    call number_entry
130
    jmp  still
107 heavyiron 131
 
132
   no_a_f:
31 halyavin 133
    cmp  eax,12
153 heavyiron 134
    jb   no_13
31 halyavin 135
    cmp  eax,14
153 heavyiron 136
    jg   no_13
31 halyavin 137
    sub  eax,11
138
    call number_entry
139
    jmp  still
107 heavyiron 140
 
31 halyavin 141
   no_13:
107 heavyiron 142
    cmp  eax,19
153 heavyiron 143
    jb   no_46
107 heavyiron 144
    cmp  eax,21
153 heavyiron 145
    jg   no_46
107 heavyiron 146
    sub  eax,15
31 halyavin 147
    call number_entry
148
    jmp  still
107 heavyiron 149
 
31 halyavin 150
   no_46:
107 heavyiron 151
    cmp  eax,26
153 heavyiron 152
    jb   no_79
107 heavyiron 153
    cmp  eax,28
153 heavyiron 154
    jg   no_79
107 heavyiron 155
    sub  eax,19
31 halyavin 156
    call number_entry
157
    jmp  still
107 heavyiron 158
 
31 halyavin 159
   no_79:
107 heavyiron 160
    cmp  eax,34
31 halyavin 161
    jne  no_0
153 heavyiron 162
    xor  eax,eax
31 halyavin 163
    call number_entry
164
    jmp  still
107 heavyiron 165
 
166
   no_0:
167
    cmp  eax,35
31 halyavin 168
    jne  no_id
169
    inc  [id]
170
    and  [id],1
171
    mov  [new_dec],100000
172
    jmp  still
107 heavyiron 173
 
31 halyavin 174
  no_id:
107 heavyiron 175
    cmp  eax,17
31 halyavin 176
    jne  no_sin
177
    fld  [trans1]
178
    fsin
179
    jmp  show_result
107 heavyiron 180
 
31 halyavin 181
  no_sin:
107 heavyiron 182
    cmp  eax,18
183
    jne  no_asin
184
    fld  [trans1]
185
    fld  st0
186
    fmul st,st1
187