1,21 → 1,25 |
;; Calculator for MenuetOS |
;; Calculator for MenuetOS (original version) |
;; (c)Ville Turjanmaa |
;; Compile with FASM for Menuet |
;; |
;; «ìªã«ïâ®à 1.1 alpha |
;; (c)Pavel Rymovski aka Heavyiron |
;;What's new:1)changed design |
;;What's new: |
;; Calc 1.1 |
;; 1)changed design |
;; 2)new procedure of draw window (10 decimal digits, 23 binary, "+" not displayed now) |
;; 3)window with skin |
;; 4)I had used macroses |
;; Calc 1.2 alpha |
;; Calc 1.2 |
;; 1)added some useful functions, such as arcsin, arccos, arctg, 1/x, x^2 |
;; Calc 1.3 |
;; Calc 1.31 |
;; 1)optimised program |
;; 2)new type of window (you need kernel 114 revision or higher) |
;; Pavel Rymovski (Heavyiron) |
|
appname equ 'Calc ' |
version equ '1.31' |
|
use32 |
org 0x0 |
|
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; start of code |
41,12 → 45,14 |
jz key |
|
button: |
mcall 17 ; ¯®«ãç¨âì ¨¤¥â¨ä¨ª â®à ¦ ⮩ ª®¯ª¨ |
mov al,17 ; ¯®«ãç¨âì ¨¤¥â¨ä¨ª â®à ¦ ⮩ ª®¯ª¨ |
int 0x40 |
shr eax,8 |
jmp testbut |
|
key: |
mcall 2 ; ¯®«ãç¨âì ASCII-ª®¤ ¦ ⮩ ª« ¢¨è¨ |
mov al,2 ; ¯®«ãç¨âì ASCII-ª®¤ ¦ ⮩ ª« ¢¨è¨ |
int 0x40 |
shr eax,8 |
mov edi,asci ; ¯¥à¥¢®¤ ASCII ¢ ¨¤¥â¨ä¨ª â®à ª®¯ª¨ |
mov ecx,18 |
62,7 → 68,8 |
testbut: |
cmp eax,1 ; ª®¯ª 1 - § ªàë⨥ ¯à®£à ¬¬ë |
jne noclose |
mcall -1 |
or eax,-1 |
int 0x40 |
|
noclose: |
cmp eax,2 |
148,7 → 155,7 |
no_79: |
cmp eax,34 |
jne no_0 |
mov eax,0 |
xor eax,eax |
call number_entry |
jmp still |
|
636,94 → 643,161 |
ret |
|
; ********************************************* |
; *******
******** |
; ******* WINDOW DEFINITIONS AND DRAW ********* |
; ********************************************* |
|
draw_window: |
|
mcall 12,1 |
mcall 0,200*65536+255,200*65536+180,0x03ddeeff ; äãªæ¨ï 0: ®¯à¥¤¥«¨âì ¨ ®âà¨á®¢ âì ®ª® |
mcall 4,8*65536+8,0x10000000,labelt,label_len ; |
mov eax,48 |
mov ebx,3 |
mov ecx,sc |
mov edx,sizeof.system_colors |
int 0x40 |
|
mov ebx,24*65536+28 |
mov ecx,70*65536+18 |
mov eax,12 |
mov ebx,1 |
int 0x40 |
|
mov eax,0 |
mov ebx,200*65536+255 |
mov ecx,200*65536+180 |
mov edx,[sc.work] |
or edx,0x33000000 |
mov edi,header |
int 0x40 |
|
mov eax,8 |
mov ebx,19*65536+28 |
mov ecx,49*65536+18 |
mov edx,6 |
mov esi,0x0066ee |
mov esi,[sc.work_button] |
mov edi,7 |
newbutton: |
dec edi |
jnz no_new_row |
mov edi,7 |
mov ebx,24*65536+25+3 |
mov ebx,19*65536+28 |
add ecx,20*65536 |
no_new_row: |
mcall 8 |
int 0x40 |
add ebx,30*65536 |
inc edx |
cmp edx,39 |
jbe newbutton |
|
mcall 8,225*65536+8,28*65536+8,3 ; 'dec-bin-hex' |
mcall 8,204*65536+28,70*65536+18,2,0xcc0000 ; 'C' |
mcall ,199*65536+28,49*65536+18,2 ; 'C' |
mcall ,220*65536+8,7*65536+8,3 ; 'dec-bin-hex' |
|
mov ebx,25*65536+75 ; à®à¨á®¢ª ¯®¤¯¨á¥© ª®¯®ª |
mov ecx,0xffffff |
mov eax,4 |
mov ebx,27*65536+54 |
mov ecx,[sc.work_button_text] |
mov edx,text |
mov esi,34 |
|
mov esi,33 |
newline: |
mcall 4 |
int 0x40 |
add ebx,20 |
add edx,34 |
add edx,33 |
cmp [edx],byte 'x' |
jne newline |
|
call print_display |
mcall 12,2 |
|
mov eax,12 |
mov ebx,2 |
int 0x40 |
|
ret |
|
print_display: |
pusha |
mcall 13,100*65536+120,25*65536+13,0x00ddeeff |
mcall 13,23*65536+210,40*65536+13,0xffffff |
mcall 4,140*65536+28,0,calc,1 |
mcall 13,18*65536+210,19*65536+13,0xffffff |
|
mov eax,4 |
mov ebx,203*65536+29 |
mov ecx,0 |
mov ebx,135*65536+7 |
mov ecx,[sc.work_text] |
or ecx,0x40000000 |
mov edx,calc |
mov esi,1 |
mov edi,[sc.work] |
int 0x40 |
|
mov ebx,198*65536+8 |
mov edx,[display_type] |
shl edx,2 |
add edx,display_type_text |
mov esi,3 |
mov edi,[sc.work] |
int 0x40 |
|
cmp [dsign],byte '+' |
je positive |
mcall 4,28*65536+43,0x0,dsign,1 |
mov ebx,23*65536+22 |
mov ecx,0x0 |
mov edx,dsign |
mov esi,1 |
int 0x40 |
|
positive: |
cmp [display_type],0 ; ¤¥áïâ¨ç ï á¨á⥬ áç¨á«¥¨ï |
cmp [display_type],0 |
jne no_display_decimal |
cmp [decimal],0 |
je whole |
mcall 47,10*65536,[integer],125*65536+43,0x0 ; ®â®¡à ¦ âì 10 æ¨äà |
mcall 4,185*65536+43,0x0,dot,1 |
mcall 47,6*65536,[decimal],192*65536+43,0x0 ; ®â®¡à ¦ âì 6 æ¨äà ¯®á«¥ § ¯ï⮩ |
|
mov ebx,180*65536+22 |
mov ecx,0x0 |
mov edx,dot |
mov esi,1 |
int 0x40 |
|
mov eax,47 |
mov ebx,10*65536 |
mov ecx,[integer] |
mov edx,120*65536+22 |
mov esi,0x0 |
int 0x40 |
|
mov ebx,6*65536 |
mov ecx,[decimal] |
mov edx,187*65536+22 |
mov esi,0x0 |
int 0x40 |
|
popa |
ret |
|
whole: |
mov ebx,220*65536+22 |
mov ecx,0x0 |
mov edx,dot |
mov esi,1 |
int 0x40 |
|
cmp [integer],0 |
je null |
mcall 47,10*65536,[integer],165*65536+43,0x0 |
mcall 4,225*65536+43,0x0,dot,1 |
|
mov eax,47 |
mov ebx,10*65536 |
mov ecx,[integer] |
mov edx,160*65536+22 |
mov esi,0x0 |
int 0x40 |
|
popa |
ret |
|
no_display_decimal: |
cmp [display_type],1 |
jne no_display_hexadecimal |
cmp [integer],0 |
je null |
cmp [display_type],1 |
jne no_display_hexadecimal |
mcall 47,1*256+8*65536,[integer],178*65536+43,0x0 ; ®â®¡à ¦ âì 8 è¥áâ ¤æ â¨à¨çëå æ¨äà |
|
mov eax,47 |
mov ebx,256+8*65536 |
mov ecx,[integer] |
mov edx,173*65536+22 |
mov esi,0x0 |
int 0x40 |
|
popa |
ret |
|
730,19 → 804,25 |
no_display_hexadecimal: |
cmp [integer],0 |
je null |
cmp [display_type],2 |
jne null |
mcall 47,2*256+32*65536,[integer],37*65536+43,0x0 ; ®â®¡à ¦ âì 32 ¤¢®¨çë¥ æ¨äàë |
|
mov eax,47 |
mov ebx,2*256+32*65536 |
mov ecx,[integer] |
mov edx,32*65536+22 |
mov esi,0x0 |
int 0x40 |
|
popa |
ret |
|
null: |
mcall 47,1*65536,0,219*65536+43,0x0 |
cmp [display_type],0 |
jne end_pr |
mcall 4,225*65536+43,0x0,dot,1 |
mov eax,47 |
mov ebx,1*65536 |
mov ecx,0 |
mov edx,214*65536+22 |
mov esi,0x0 |
int 0x40 |
|
end_pr: |
popa |
ret |
|
768,12 → 848,12 |
ret |
|
|
;¡« áâì ¤ ëå |
;data |
|
header db appname,version,0 |
|
display_type dd 0 ; 0 = decimal, 1 = hexadecimal, 2= binary |
entry_multiplier dd 10 |
|
display_start_y dd 0x0 |
display_type_text db 'dec hex bin' |
|
dot db '.' |
797,7 → 877,7 |
|
asci: db 49,50,51,52,53,54,55,56,57,48,43,61,45,42,47,44,46,27 |
butid: db 12,13,14,19,20,21,26,27,28,34,15,39,22,36,29,35,35,1 |
labelt: |
db 'Calc 1.3' |
label_len = $ - labelt |
I_END: |
|
I_END: |
|
sc system_colors |