Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 153 → Rev 152

/programs/other/calc/trunk/calc.asm
1,25 → 1,21
;; Calculator for MenuetOS (original version)
;; Calculator for MenuetOS
;; (c)Ville Turjanmaa
;; Compile with FASM for Menuet
;;
;;What's new:
;; Calc 1.1
;; 1)changed design
;; Š «ìªã«ïâ®à 1.1 alpha
;; (c)Pavel Rymovski aka Heavyiron
;;What's new: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
;; Calc 1.2 alpha
;; 1)added some useful functions, such as arcsin, arccos, arctg, 1/x, x^2
;; Calc 1.31
;; Calc 1.3
;; 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
45,14 → 41,12
jz key
button:
mov al,17 ; ¯®«ãç¨âì ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª­®¯ª¨
int 0x40
mcall 17 ; ¯®«ãç¨âì ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª­®¯ª¨
shr eax,8
jmp testbut
 
key:
mov al,2 ; ¯®«ãç¨âì ASCII-ª®¤ ­ ¦ â®© ª« ¢¨è¨
int 0x40
mcall 2 ; ¯®«ãç¨âì ASCII-ª®¤ ­ ¦ â®© ª« ¢¨è¨
shr eax,8
mov edi,asci ; ¯¥à¥¢®¤ ASCII ¢ ¨¤¥­â¨ä¨ª â®à ª­®¯ª¨
mov ecx,18
68,8 → 62,7
testbut:
cmp eax,1 ; ª­®¯ª  1 - § ªàë⨥ ¯à®£à ¬¬ë
jne noclose
or eax,-1
int 0x40
mcall -1
noclose:
cmp eax,2
155,7 → 148,7
no_79:
cmp eax,34
jne no_0
xor eax,eax
mov eax,0
call number_entry
jmp still
643,161 → 636,94
ret
 
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW *********
; ******* Ž…„…‹…ˆ… ˆ Ž’ˆ‘Ž‚Š€ ŽŠ€ ********
; *********************************************
 
draw_window:
mov eax,48
mov ebx,3
mov ecx,sc
mov edx,sizeof.system_colors
int 0x40
mcall 12,1
mcall 0,200*65536+255,200*65536+180,0x03ddeeff ; äã­ªæ¨ï 0: ®¯à¥¤¥«¨âì ¨ ®âà¨á®¢ âì ®ª­®
mcall 4,8*65536+8,0x10000000,labelt,label_len ; ‡€ƒŽ‹Ž‚ŽŠ ŽŠ€
 
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 ebx,24*65536+28
mov ecx,70*65536+18
mov edx,6
mov esi,[sc.work_button]
mov esi,0x0066ee
mov edi,7
newbutton:
dec edi
jnz no_new_row
mov edi,7
mov ebx,19*65536+28
mov ebx,24*65536+25+3
add ecx,20*65536
no_new_row:
int 0x40
mcall 8
add ebx,30*65536
inc edx
cmp edx,39
jbe newbutton
mcall ,199*65536+28,49*65536+18,2 ; 'C'
mcall ,220*65536+8,7*65536+8,3 ; 'dec-bin-hex'
mcall 8,225*65536+8,28*65536+8,3 ; 'dec-bin-hex'
mcall 8,204*65536+28,70*65536+18,2,0xcc0000 ; 'C'
 
mov eax,4
mov ebx,27*65536+54
mov ecx,[sc.work_button_text]
mov ebx,25*65536+75 ; à®à¨á®¢ª  ¯®¤¯¨á¥© ª­®¯®ª
mov ecx,0xffffff
mov edx,text
mov esi,33
mov esi,34
newline:
int 0x40
mcall 4
add ebx,20
add edx,33
add edx,34
cmp [edx],byte 'x'
jne newline
call print_display
mov eax,12
mov ebx,2
int 0x40
 
mcall 12,2
ret
 
print_display:
pusha
mcall 13,18*65536+210,19*65536+13,0xffffff
 
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
mov eax,4
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 ebx,203*65536+29
mov ecx,0
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
mov ebx,23*65536+22
mov ecx,0x0
mov edx,dsign
mov esi,1
int 0x40
mcall 4,28*65536+43,0x0,dsign,1
positive:
cmp [display_type],0
cmp [display_type],0 ; ¤¥áïâ¨ç­ ï á¨á⥬  áç¨á«¥­¨ï
jne no_display_decimal
cmp [decimal],0
je whole
 
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
 
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 æ¨äà ¯®á«¥ § ¯ï⮩
popa
ret
whole:
mov ebx,220*65536+22
mov ecx,0x0
mov edx,dot
mov esi,1
int 0x40
 
cmp [integer],0
je null
 
mov eax,47
mov ebx,10*65536
mov ecx,[integer]
mov edx,160*65536+22
mov esi,0x0
int 0x40
 
mcall 47,10*65536,[integer],165*65536+43,0x0
mcall 4,225*65536+43,0x0,dot,1
popa
ret
no_display_decimal:
cmp [integer],0
je null
cmp [display_type],1
jne no_display_hexadecimal
cmp [integer],0
je null
mov eax,47
mov ebx,256+8*65536
mov ecx,[integer]
mov edx,173*65536+22
mov esi,0x0
int 0x40
 
mcall 47,1*256+8*65536,[integer],178*65536+43,0x0 ; ®â®¡à ¦ âì 8 è¥áâ­ ¤æ â¨à¨ç­ëå æ¨äà
popa
ret
804,25 → 730,19
no_display_hexadecimal:
cmp [integer],0
je null
 
mov eax,47
mov ebx,2*256+32*65536
mov ecx,[integer]
mov edx,32*65536+22
mov esi,0x0
int 0x40
 
cmp [display_type],2
jne null
mcall 47,2*256+32*65536,[integer],37*65536+43,0x0 ; ®â®¡à ¦ âì 32 ¤¢®¨ç­ë¥ æ¨äàë
popa
ret
null:
mov eax,47
mov ebx,1*65536
mov ecx,0
mov edx,214*65536+22
mov esi,0x0
int 0x40
mcall 47,1*65536,0,219*65536+43,0x0
cmp [display_type],0
jne end_pr
mcall 4,225*65536+43,0x0,dot,1
 
end_pr:
popa
ret
 
848,12 → 768,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 '.'
877,7 → 797,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
 
I_END:
 
sc system_colors
labelt:
db 'Calc 1.3'
label_len = $ - labelt
I_END:
/programs/other/calc/trunk/build_en.bat
1,5 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm calc.asm calc
@erase lang.inc
@pause
/programs/other/calc/trunk/build_ru.bat
1,5 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm calc.asm calc
@erase lang.inc
@pause
/programs/network/https/trunk/https.asm
1,21 → 1,18
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; Tiny HTTP Server v 0.5 for KolibriOS ;
; Tiny HTTP Server v 0.4 for MenuetOS ;
; ;
; License GPL / See file COPYING for details. ;
; Copyright 2003 Ville Turjanmaa ;
; ;
; Compile with FASM for Menuet/KolibriOS ;
; Compile with FASM for Menuet ;
; ;
; Request /TinyStat for server statistics ;
; Request /TinyBoard for server message board ;
; ;
; Special version for KoOS by Hex && Heavyiron ;
; ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
appname equ 'Kolibri HTTP Server '
version equ '0.6'
version equ '0.4'
 
use32
 
29,7 → 26,8
dd 0x20000
dd 0,0 ; reserved=no extended header
 
include "MACROS.INC"
include 'lang.inc'
include "macros.inc"
 
; 0x0+ - program image
; 0x1ffff - stack
37,25 → 35,18
; 0x100000+ - requested file
 
filel:
dd 0
dd 0
dd 0
dd 50000
dd 0x20000
dd 0x0,0x0,50000/512,0x20000,0x70000
db '/rd/1/board.htm',0
 
files:
dd 2
dd 0
dd 0
dd 0
dd 0x20000
dd 0x1,0x0,0x0,0x20000,0x70000
db '/rd/1/board.htm',0
 
 
 
START: ; start of execution
 
mov eax,70
mov eax,58
mov ebx,filel
int 0x40
mov [board_size],ebx
71,18 → 62,19
 
board_found:
 
mov eax,70
mov eax,58
mov ebx,files
mov ecx,[board_size]
mov [files+12],ecx
mov [files+8],ecx
int 0x40
 
mov [status],-1
mov [last_status],-2
call clear_input
red:
call draw_window ; at first, draw the window
 
; call ops
 
still:
 
call check_status
106,6 → 98,16
 
jmp still
 
 
reb: ; boot
 
mov eax,18
mov ebx,1
int 0x40
 
jmp $
 
 
last_status dd 0x0
 
check_events:
119,14 → 121,18
 
ret
 
red: ; redraw
call draw_window
ret
 
key: ; Keys are not valid at this part of the
mov al,2 ; loop. Just read it and ignore
mov eax,2 ; loop. Just read it and ignore
int 0x40
ret
 
button: ; button
 
mov al,17 ; get id
mov eax,17 ; get id
int 0x40
 
cmp ah,1 ; close
158,8 → 164,11
call draw_data
mov [server_active],1
call check_status
; cmp [status],0
; je reb
ret
tst3:
 
cmp ah,4 ; button id=4 ?
jnz no4
mov [server_active],0
310,6 → 319,14
 
wait_more:
 
; rdtsc
; mov ecx,eax
; add ecx,1000000
; wr:
; rdtsc
; cmp eax,ecx
; jb wr
 
mov eax,5
mov ebx,1
int 0x40
380,12 → 397,9
popa
ret
 
fileinfo dd 0
dd 0
dd 0
dd 512
dd 0x100000
getf db '/rd/1/'
 
fileinfo dd 0,0,1,0x100000,0xf0000
getf db '/RD/1/'
times 50 db 0
wanted_file: times 100 db 0
 
420,9 → 434,9
 
read_file: ; start of execution
 
mov [fileinfo+16],eax
shl ebx, 9
mov [fileinfo+12],ebx
mov [fileinfo+12],eax
mov [fileinfo+8],ebx
 
mov [file_type],unk
mov [type_len],unkl-unk
mov [filename+40*2+6],dword 'UNK '
435,7 → 449,7
 
yes_new_message:
 
mov eax,70
mov eax,58
mov ebx,filel
int 0x40
mov [board_size],ebx
471,7 → 485,6
je name_found_len
inc edx
jmp name_new_len
 
name_found_len:
 
mov [from_len],edx
561,8 → 574,7
 
mov esi,[from_i] ; name
mov edi,0x20000
add edi,board1-board
add edi,board1e-board1
add edi,board1-board + board1e-board1
mov ecx,[from_len]
cld
rep movsb
595,9 → 607,9
inc [board_messages]
 
mov eax,[board_size]
mov [files+12],eax
mov [files+8],eax
 
mov eax,70
mov eax,58
mov ebx,files
int 0x40
 
766,8 → 778,8
cld
rep movsb
 
mov [fileinfo+12],dword 1 ; file exists ?
mov eax,70
mov [fileinfo+8],dword 1 ; file exists ?
mov eax,58
mov ebx,fileinfo
int 0x40
 
792,8 → 804,8
 
file_found:
 
mov [fileinfo+12],dword 0x2f0000 ; read all of file
mov eax,70
mov [fileinfo+8],dword 0x2f0000 / 512 ; read all of file
mov eax,58
mov ebx,fileinfo
int 0x40
 
1076,13 → 1088,20
 
pusha
 
mov eax,13
mov ebx,97*65536+23*6
mov ecx,[ya]
shl ecx,16
mov cx,9
mov edx,0xffffff
int 0x40
 
mov eax,4
mov edx,[addr]
mov ebx,97*65536
add ebx,[ya]
mov ecx,0x40000000
mov ecx,0x000000
mov esi,23
mov edi,0xffffff
int 0x40
 
popa
1089,6 → 1108,10
ret
 
 
 
 
 
 
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
1104,10 → 1127,19
mov eax,0 ; function 0 : define and draw window
mov ebx,100*65536+480 ; [x start] *65536 + [x size]
mov ecx,100*65536+215 ; [y start] *65536 + [y size]
mov edx,0x13ffffff ; color of work area RRGGBB
mov edi,header ; WINDOW LABEL
mov edx,0x03ffffff ; color of work area RRGGBB
mov esi,0x8050a0b0 ; color of grab bar RRGGBB,8->color gl
mov edi,0x0050a0b0 ; color of frames RRGGBB
int 0x40
 
; WINDOW LABEL
mov eax,4 ; function 4 : write text to window
mov ebx,8*65536+8 ; [x start] *65536 + [y start]
mov ecx,0x10ffffff ; color of text RRGGBB
mov edx,labelt ; pointer to text beginning
mov esi,labellen-labelt ; text length
int 0x40
 
mov eax,8 ; function 8 : define and draw button
mov ebx,(40)*65536+20 ; [x start] *65536 + [x size]
mov ecx,59*65536+9 ; [y start] *65536 + [y size]
1115,7 → 1147,7
mov esi,0x66aa66 ; button color RRGGBB
int 0x40
 
; function 8 : define and draw button
mov eax,8 ; function 8 : define and draw button
mov ebx,(40)*65536+20 ; [x start] *65536 + [x size]
mov ecx,72*65536+9 ; [y start] *65536 + [y size]
mov edx,4 ; button id
1122,7 → 1154,7
mov esi,0xaa6666 ; button color RRGGBB
int 0x40
 
; Enter directory
mov eax,8 ; Enter directory
mov ebx,(25)*65536+66
mov ecx,135*65536+15
mov edx,6
1135,7 → 1167,7
mov edx,0x6699cc ; 002288
int 0x40
 
 
mov eax,38
mov ebx,241*65536+241
mov ecx,22*65536+210
mov edx,0x336699 ; 002288
1227,7 → 1259,7
db ' /TinyBoard -message board '
db ' '
dirp:
db ' Files: /rd/1/ '
db ' Files: /RD/1/ '
db ' '
filename:
db ' '
1239,7 → 1271,7
html_header:
 
db 'HTTP/1.0 200 OK',13,10
db 'Server: KolibriOS HTTP Server',13,10
db 'Server: MenuetOS HTTP Server',13,10
db 'Content-Length: '
c_l: db '000000',13,10
 
1248,9 → 1280,9
fnf:
db '<body>'
db '<pre>'
db "HTTP-Ñåðâåð v ",version," äëÿ KolibriOS",13,10,13,10
db "<H1>Error <FONT color=red>404</FONT> - File not found</H1>",13,10,13,10
db "Äëÿ ïîëó÷åíèÿ ñòàòèñòèêè âûïîëíèòå çàïðîñ /TinyStat",13,10,13,10
db "TinyServer v ",version," for MenuetOS",13,10,13,10
db "Error 404 - File not found.",13,10,13,10
db "For more info about server: request /TinyStat",13,10,13,10
et: db "xx:xx:xx",13,10
ed: db "xx.xx.xx",13,10
db "</pre></body>"
1260,15 → 1292,15
sm:
db '<body>'
db '<pre>'
db "HTTP-Ñåðâåð v ",version," äëÿ KolibriOS",13,10,13,10
db "Ñòàòèñòèêà: (ïîñëå äàííîãî çàïðîñà)",13,10,13,10
sms: db "- Äîêóìåíòîâ ïðèíÿòî: xxxxxxxxx",13,10
smb: db "- Áàéò ïåðåäàííî : xxxxxxxxx",13,10
db "- Ìåñòîíàõîæäåíèå : <a href=/TinyStat>Ñòàòèñòèêà</a>",13,10,13,10
db "Ãîñòåâàÿ:",13,10,13,10
smm: db "- Ñîîáùåíèé : xxxxxxxxx",13,10
smz: db "- Ðàçìåð â áàéòàõ : xxxxxxxxx",13,10
db "- Ìåñòîíàõîæäåíèå : <a href=/TinyBoard>Ãîñòåâàÿ</a>",13,10,13,10
db "TinyServer v ",version," for MenuetOS",13,10,13,10
db "Statistics: (before current request)",13,10,13,10
sms: db "- Documents served : xxxxxxxxx",13,10
smb: db "- Bytes transferred : xxxxxxxxx",13,10
db "- Location : <a href=/TinyStat>/TinyStat</a>",13,10,13,10
db "TinyBoard:",13,10,13,10
smm: db "- Messages : xxxxxxxxx",13,10
smz: db "- Size in bytes : xxxxxxxxx",13,10
db "- Location : <a href=/TinyBoard>/TinyBoard</a>",13,10,13,10
smt: db "xx:xx:xx",13,10
smd: db "xx.xx.xx",13,10
db '</pre></body>'
1294,7 → 1326,8
unkl:
 
 
header db appname,version,0
labelt: db 'Tiny http server ',version
labellen:
 
socket dd 0x0
server_active db 0x0
1301,13 → 1334,12
 
board:
 
db "<HTML><HEAD><TITLE>INTKolibriOS - /Ãîñòåâàÿ/</TITLE></HEAD>",13,10
db "<BODY background=bgnd.gif BGCOLOR=#ffffff ALINK=black VLINK=black><br>",13,10
db "<HTML><BODY BGCOLOR=#ffffff ALINK=black VLINK=black><br>",13,10
db "<center>",13,10
db "<TABLE CELLPADDING=10 CELLSPACING=0 BORDER=0 bgcolor=#ffffff width=600>"
db 13,10
db "<TR VALIGN=top><TD ALIGN=center bgcolor=F4F4F4>",13,10
db "<font size=4>Ãîñòåâàÿ ñåðâåðà INTKolibriOS</TD></TR></TABLE><br>",13,10
db "<TR VALIGN=top><TD ALIGN=center bgcolor=f0f0f8>",13,10
db "<font size=3>Tinyserver Messageboard</TD></TR></TABLE><br>",13,10
db "<TABLE CELLPADDING=14 CELLSPACING=2 BORDER=0 bgcolor=#ffffff width=600>"
db 13,10,13,10
 
1314,22 → 1346,22
board1:
 
db "<TR VALIGN=top>",13,10
db "<TD ALIGN=left width=80 bgcolor=F4F4F4><P>",13,10
db "<TD ALIGN=left width=80 bgcolor=f0f0f8><P>",13,10
db "<font size=3>",13,10
board1e:
db "Hex",13,10
db "WebMaster",13,10
board2:
db "</font>",13,10
db "<br><br><br>",13,10
db "<br><br><br><br>",13,10
bsmt:
db "15.23.45<br>",13,10
db "12.23.45<br>",13,10
bsmd:
db "22.03.06",13,10
db "02.05.03",13,10
db "</P></TD>",13,10
db "<TD bgcolor=F4F4F4><P>",13,10
db "<TD bgcolor=f0f0f8><P>",13,10
board2e:
db "Äîáðî ïîæàëîâàòü â ãîñòåâóþ ñåðâåðà INTKolibriOS! (-:<br>"
db "Assembly written messageboard from assembly written MenuetOS.<br>"
db 13,10
board3:
db "</P></TD></TR>",13,10,13,10
1342,11 → 1374,11
db "<TABLE CELLPADDING=14 CELLSPACING=3 BORDER=0 bgcolor=#ffffff width=600>"
db 13,10
db "<TR VALIGN=top>",13,10
db "<TD ALIGN=left bgcolor=F4F4F4><P>",13,10
db "<TD ALIGN=left bgcolor=f0f0f8><P>",13,10
db "<form method=Post Action=/TinyBoard>",13,10
db "Èìÿ: <br><input type=text name=from size=20 MAXLENGTH=20><br>",13,10
db "Ñîîáùåíèå: <br><textarea cols=60 rows=6 name=message></textarea><br>",13,10
db "<input type=Submit Value=' Îòïðàâèòü ñîîáùåíèå '></form>",13,10
db "Name: <br><input type=text name=from size=20 MAXLENGTH=20><br>",13,10
db "Message: <br><textarea cols=60 rows=6 name=message></textarea><br>",13,10
db "<input type=Submit Value=' Send Message '></form>",13,10
db "</TD></TR>",13,10
db "</TABLE>",13,10
db "</BODY>",13,10