Rev 205 | Rev 485 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 205 | Rev 382 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ;; Calculator for MenuetOS (original version) |
1 | ;; Calculator for MenuetOS (c) Ville Turjanmaa |
2 | ;; (c)Ville Turjanmaa |
2 | ;; |
3 | ;; Compile with FASM for Menuet |
3 | ;; Compile with FASM for Menuet |
4 | ;; |
4 | ;; |
- | 5 | ;; Pavel Rymovski (Heavyiron) - kolibri version |
|
5 | ;;What's new: |
6 | ;; What's new: |
6 | ;; Calc 1.1 |
7 | ;; Calc 1.1 |
7 | ;; 1)changed design |
8 | ;; 1) changed design |
8 | ;; 2)new procedure of draw window (10 decimal digits, 23 binary, "+" not displayed now) |
9 | ;; 2) new procedure of draw window (10 decimal digits, 23 binary, "+" not displayed now) |
9 | ;; 3)window with skin |
10 | ;; 3) window with skin |
10 | ;; 4)I had used macroses |
11 | ;; 4) used macroses |
11 | ;; Calc 1.2 |
12 | ;; Calc 1.2 |
12 | ;; 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 |
13 | ;; Calc 1.31 |
14 | ;; Calc 1.31 |
14 | ;; 1)optimised program |
15 | ;; 1)optimised program |
15 | ;; 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 |
|
16 | ;; Pavel Rymovski (Heavyiron) |
18 | ;; 1)fixed arccos |
- | 19 | ||
Line 17... | Line 20... | ||
17 | 20 | ||
18 | appname equ 'Calc ' |
21 | appname equ 'Calc ' |
Line 19... | Line 22... | ||
19 | version equ '1.31' |
22 | version equ '1.32' |
20 | 23 | ||
21 | use32 |
24 | use32 |
22 | org 0x0 |
25 | org 0x0 |
23 | db 'MENUET01' ; 8 byte id |
26 | db 'MENUET01' ; 8 byte id |
24 | dd 0x01 ; header version |
27 | dd 0x01 ; header version |
25 | dd START ; start of code |
28 | dd START ; start of code |
26 | dd I_END ; size of image |
29 | dd I_END ; size of image |
27 | dd 0x1000 ; memory for app |
30 | dd 0x1000 ; memory for app |
Line 28... | Line 31... | ||
28 | dd 0x1000 ; esp |
31 | dd 0x1000 ; esp |
Line 29... | Line 32... | ||
29 | dd 0x0,0x0 ; I_Param , I_Icon |
32 | dd 0x0,0x0 ; I_Param , I_Icon |
Line -... | Line 33... | ||
- | 33 | ||
- | 34 | include 'macros.inc' |
|
- | 35 | ||
- | 36 | START: |
|
- | 37 | ||
- | 38 | mov eax,48 |
|
30 | 39 | mov ebx,3 |
|
31 | include 'macros.inc' |
40 | mov ecx,sc |
Line 32... | Line 41... | ||
32 | 41 | mov edx,sizeof.system_colors |
|
33 | START: |
42 | int 0x40 |
Line 113... | Line 122... | ||
113 | mov eax,[display_type] |
122 | mov eax,[display_type] |
114 | mov eax,[multipl+eax*4] |
123 | mov eax,[multipl+eax*4] |
115 | mov [entry_multiplier],eax |
124 | mov [entry_multiplier],eax |
116 | call print_display |
125 | call print_display |
117 | jmp still |
126 | jmp still |
118 | multipl: dd 10,16,2 |
- | |
Line 119... | Line 127... | ||
119 | 127 | ||
120 | no_display_change: |
128 | no_display_change: |
121 | cmp eax,6 |
129 | cmp eax,6 |
122 | jb no_a_f |
130 | jb no_a_f |
Line 210... | Line 218... | ||
210 | 218 | ||
211 | no_cos: |
219 | no_cos: |
212 | cmp eax,25 |
220 | cmp eax,25 |
213 | jne no_acos |
221 | jne no_acos |
- | 222 | fld [trans1] |
|
- | 223 | fld st0 |
|
214 | fld [trans1] |
224 | fmul st,st1 |
215 | fld1 |
225 | fld1 |
216 | fsub st,st1 |
- | |
217 | fsqrt |
- | |
218 | fld1 |
- | |
219 | fadd st,st2 |
226 | fsubrp st1,st0 |
- | 227 | fsqrt |
|
220 | fsqrt |
228 | fxch st1 |
221 | fpatan |
- | |
222 | fadd st,st0 |
229 | fpatan |
Line 223... | Line 230... | ||
223 | jmp show_result |
230 | jmp show_result |
224 | 231 | ||
225 | no_acos: |
232 | no_acos: |
Line 439... | Line 446... | ||
439 | mov [new_dec],100000 |
446 | mov [new_dec],100000 |
440 | mov [sign],byte '+' |
447 | mov [sign],byte '+' |
441 | popa |
448 | popa |
442 | ret |
449 | ret |
Line 443... | Line -... | ||
443 | - | ||
444 | ten dd 10.0,0 |
- | |
445 | tmp dw 1,0 |
- | |
446 | sign db 1,0 |
- | |
447 | tmp2 dq 0x0,0 |
- | |
448 | exp dd 0x0,0 |
- | |
449 | new_dec dd 100000,0 |
- | |
450 | id db 0x0,0 |
- | |
451 | res dd 0 |
- | |
452 | trans1 dq 0 |
- | |
453 | trans2 dq 0 |
- | |
Line 454... | Line 450... | ||
454 | controlWord dw 1 |
450 | |
455 | 451 | ||
456 | ftoa: ; fpu st0 -> [integer],[decimal] |
452 | ftoa: ; fpu st0 -> [integer],[decimal] |
457 | pusha |
453 | pusha |
Line 469... | Line 465... | ||
469 | jne no_neg |
465 | jne no_neg |
470 | mov [sign],1 |
466 | mov [sign],1 |
Line 471... | Line 467... | ||
471 | 467 | ||
472 | no_neg: |
468 | no_neg: |
473 | fld [tmp2] |
469 | fld [tmp2] |
474 | fistp [integer] |
- | |
475 | fld [tmp2] |
470 | fist [integer] |
476 | fisub [integer] |
471 | fisub [integer] |
477 | fldcw [controlWord] |
472 | fldcw [controlWord] |
478 | cmp byte [sign], 0 ; change fraction to positive |
473 | cmp byte [sign], 0 ; change fraction to positive |
479 | je no_neg2 |
474 | je no_neg2 |
Line 560... | Line 555... | ||
560 | mov bh, 0 ; Set bh to indicate the string is a valid number. |
555 | mov bh, 0 ; Set bh to indicate the string is a valid number. |
561 | jmp .exit |
556 | jmp .exit |
Line 562... | Line 557... | ||
562 | 557 | ||
563 | .error: |
558 | .error: |
564 | mov bh, 1 ; Set error code. |
559 | mov bh, 1 ; Set error code. |
Line 565... | Line 560... | ||
565 | fstp st0 ; Pop top of fpu stack. |
560 | ; fstp st0 ; Pop top of fpu stack. |
566 | 561 | ||
567 | .exit: |
562 | .exit: |
568 | pop di |
563 | pop di |
Line 650... | Line 645... | ||
650 | ; ******* WINDOW DEFINITIONS AND DRAW ********* |
645 | ; ******* WINDOW DEFINITIONS AND DRAW ********* |
651 | ; ********************************************* |
646 | ; ********************************************* |
Line 652... | Line 647... | ||
652 | 647 | ||
Line 653... | Line -... | ||
653 | draw_window: |
- | |
654 | - | ||
655 | mov eax,48 |
- | |
656 | mov ebx,3 |
- | |
657 | mov ecx,sc |
- | |
658 | mov edx,sizeof.system_colors |
- | |
659 | int 0x40 |
648 | draw_window: |
660 | 649 | ||
661 | mov eax,12 |
650 | mov eax,12 |
Line 662... | Line 651... | ||
662 | mov ebx,1 |
651 | mov ebx,1 |
Line 687... | Line 676... | ||
687 | add ebx,30 shl 16 |
676 | add ebx,30 shl 16 |
688 | inc edx |
677 | inc edx |
689 | cmp edx,39 |
678 | cmp edx,39 |
690 | jbe newbutton |
679 | jbe newbutton |
Line 691... | Line 680... | ||
691 | 680 | ||
692 | mcall ,199 shl 16+28,49 shl 16+18,2 ; 'C' |
681 | mcall ,199 shl 16+28,49 shl 16+18,2 ; 'C' |
Line 693... | Line 682... | ||
693 | mcall ,220 shl 16+8,7 shl 16+8,3 ; 'dec-bin-hex' |
682 | mcall ,220 shl 16+8,7 shl 16+8,3 ; 'dec-bin-hex' |
694 | 683 | ||
695 | mov eax,4 |
684 | mov eax,4 |
Line 858... | Line 847... | ||
858 | 847 | ||
859 | display_type dd 0 ; 0 = decimal, 1 = hexadecimal, 2= binary |
848 | display_type dd 0 ; 0 = decimal, 1 = hexadecimal, 2= binary |
860 | entry_multiplier dd 10 |
849 | entry_multiplier dd 10 |
Line 861... | Line 850... | ||
861 | display_type_text db 'dec hex bin' |
850 | display_type_text db 'dec hex bin' |
862 | 851 | ||
863 | dot db '.' |
852 | dot db '.' |
864 | calc db ' ' |
853 | calc db ' ' |
865 | integer dd 0 |
854 | integer dd 0 |
- | 855 | decimal dd 0 |
|
- | 856 | kymppi dd 10 |
|
- | 857 | ten dd 10.0,0 |
|
- | 858 | tmp dw 1,0 |
|
- | 859 | sign db 1,0 |
|
- | 860 | tmp2 dq 0x0,0 |
|
- | 861 | exp dd 0x0,0 |
|
- | 862 | new_dec dd 100000,0 |
|
- | 863 | id db 0x0,0 |
|
- | 864 | res dd 0 |
|
- | 865 | trans1 dq 0 |
|
- | 866 | trans2 dq 0 |
|
Line 866... | Line 867... | ||
866 | decimal dd 0 |
867 | controlWord dw 1 |
867 | kymppi dd 10 |
868 | multipl: dd 10,16,2 |
868 | 869 | ||
869 | dsign: |
870 | dsign: |