/programs/develop/examples/cpuspeed/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm cpuspeed.asm cpuspeed |
@pause |
/programs/develop/examples/cpuspeed/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm cpuspeed.asm cpuspeed |
@pause |
/programs/develop/examples/cpuspeed/trunk/cpuspeed.asm |
---|
0,0 → 1,153 |
; |
; CPU SPEED INDICATIOR |
; |
; Compile with FASM for Menuet |
; |
use32 |
org 0x0 |
db 'MENUET00' ; 8 byte id |
dd 38 ; required os |
dd START ; program start |
dd I_END ; program image size |
dd 0x1000 ; required amount of memory |
dd 0x1000 ; esp |
dd 0x00000000 ; reserved=no extended header |
include 'lang.inc' |
include 'macros.inc' |
START: ; start of execution |
mov eax,18 |
mov ebx,5 |
int 0x40 |
xor edx,edx |
mov ebx,1000000 |
div ebx |
mov ebx,10 |
mov edi,text+19 |
mov ecx,5 |
newnum: |
xor edx,edx |
mov ebx,10 |
div ebx |
add dl,48 |
mov [edi],dl |
sub edi,1 |
loop newnum |
call draw_window ; at first, draw the window |
still: |
mov eax,10 ; wait here for event |
int 0x40 |
cmp eax,1 ; redraw request ? |
jz red |
cmp eax,2 ; key in buffer ? |
jz key |
cmp eax,3 ; button in buffer ? |
jz button |
jmp still |
red: ; redraw |
call draw_window |
jmp still |
key: ; key |
mov eax,2 ; just read it and ignore |
int 0x40 |
jmp still |
button: ; button |
mov eax,17 ; get id |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jnz still |
mov eax,-1 ; close this program |
int 0x40 |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
int 0x40 |
mov eax,48 |
mov ebx,3 |
mov ecx,sc |
mov edx,sizeof.system_colors |
int 0x40 |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,100*65536+200 ; [x start] *65536 + [x size] |
mov ecx,100*65536+65 ; [y start] *65536 + [y size] |
mov edx,[sc.work] ; color of work area RRGGBB,8->color glide |
mov esi,[sc.grab] ; color of grab bar RRGGBB,8->color |
or esi,0x80000000 |
mov edi,[sc.frame] ; 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,[sc.grab_text] ; color of text RRGGBB |
or ecx,0x10000000 |
mov edx,labelt ; pointer to text beginning |
mov esi,labellen-labelt ; text length |
int 0x40 |
; CLOSE BUTTON |
mov eax,8 ; function 8 : define and draw button |
mov ebx,(200-17)*65536+12 ; [x start] *65536 + [x size] |
mov ecx,5*65536+12 ; [y start] *65536 + [y size] |
mov edx,1 ; button id |
mov esi,[sc.grab_button] ; button color RRGGBB |
int 0x40 |
mov ebx,25*65536+35 ; draw info text with function 4 |
mov ecx,[sc.work_text] |
mov edx,text |
mov esi,40 |
newline: |
mov eax,4 |
int 0x40 |
add ebx,10 |
add edx,40 |
cmp [edx],byte 'x' |
jnz newline |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
ret |
; DATA AREA |
text: |
db 'CPU RUNNING AT MHZ ' |
db 'x' ; <- END MARKER, DONT DELETE |
labelt: |
db 'CPU SPEED' |
labellen: |
I_END: |
sc system_colors |
/programs/develop/examples/cpuspeed/trunk/macros.inc |
---|
0,0 → 1,266 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs equ <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
/programs/develop/examples/ir/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm ir.asm ir |
@pause |
/programs/develop/examples/ir/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm ir.asm ir |
@pause |
/programs/develop/examples/ir/trunk/ir.asm |
---|
0,0 → 1,268 |
; |
; INFRARED |
; |
; Compile with FASM for Menuet |
; |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 1 ; required os |
dd START ; program start |
dd I_END ; program image size |
dd 0x1000 ; required amount of memory |
dd 0x1000 ; esp = 0x7FFF0 |
dd 0, 0 |
include 'macros.inc' |
START: ; start of execution |
set_variables: |
mov eax,46 ; reserve ports 0x3f0 - 0x3ff |
mov ebx,0 |
mov ecx,0x3f0 |
mov edx,0x3ff |
int 0x40 |
mov eax,45 ; reserve irq 4 |
mov ebx,0 |
mov ecx,4 |
int 0x40 |
mov eax,44 ; set read ports for irq 4 |
mov ebx,irqtable |
; mov ecx,4 |
int 0x40 |
mov dh, 3 ; all ports have number 3xx hex |
mov dl, 0xf3+8 |
mov al, 0x80 |
out dx, al |
mov dl, 0xf1+8 |
mov al, 0 |
out dx, al |
mov dl, 0xf0+8 |
mov al, 0x30 / 4 |
out dx, al |
mov dl, 0xf3+8 |
mov al, 3 |
out dx, al |
mov dl, 0xf4+8 |
mov al, 0xB |
out dx, al |
mov dl, 0xf1+8 |
mov al, 1 |
out dx, al |
mov eax,5 |
mov ebx,100 |
int 0x40 |
mov dl, 0xf8 |
mov al, 'I' |
out dx, al |
mov eax,5 |
mov ebx,10 |
int 0x40 |
mov al, 'R' |
out dx, al |
mov eax,40 ; get com 1 data with irq 4 |
mov ebx,0000000000010000b shl 16 + 101b |
int 0x40 |
red: |
call draw_window |
still: |
mov eax,10 ; wait here for event |
int 0x40 |
dec eax |
jz red |
dec eax |
dec eax |
jnz readir |
button: ; button |
mov al,17 ; get id |
int 0x40 |
; we have only one button, close |
mov eax,45 ; free irq |
mov ebx,1 |
mov ecx,4 |
int 0x40 |
mov eax,46 ; free ports 0x3f0-0x3ff |
mov ebx,1 |
mov ecx,0x3f0 |
mov edx,0x3ff |
int 0x40 |
or eax,-1 ; close this program |
int 0x40 |
pos dd 0x0 |
cdplayer: |
dd 7 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
db '/RD/1/CDP',0 |
readir: |
mov eax,42 |
mov ebx,4 |
int 0x40 |
cmp ebx,80 |
jne nocd |
mov eax,70 |
mov ebx,cdplayer |
int 0x40 |
nocd: |
push ebx |
mov eax,[pos] |
add eax,1 |
cmp eax,10*20+1 |
jb noeaxz |
mov esi,text+10*4 |
mov edi,text |
mov ecx,10*21*4 |
cld |
rep movsb |
mov eax,13 |
mov ebx,20*65536+260 |
mov ecx,22*65536+220 |
mov edx,[wcolor] |
int 0x40 |
mov eax,10*19+1 |
noeaxz: |
mov [pos],eax |
pop ebx |
and ebx,0xff |
call draw_data |
jmp still |
draw_data: |
pusha |
xchg eax,ebx |
mov ecx,10 |
shl ebx,2 |
mov esi,3 |
newnum: |
xor edx,edx |
div ecx |
add edx,48 |
mov [ebx+text-1],dl |
dec ebx |
dec esi |
jnz newnum |
call draw_text |
popa |
ret |
irqtable: |
dd 0x3f8+0x01000000 ; + 01 = read byte, 02 read word |
dd 0 |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
int 0x40 |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,100*65536+300 ; [x start] *65536 + [x size] |
mov ecx,100*65536+250 ; [y start] *65536 + [y size] |
mov edx,[wcolor] ; color of work area RRGGBB,8->color |
mov edi,labelt ; caption string |
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,0x00ffffff ; color of text RRGGBB |
; mov edx,labelt ; pointer to text beginning |
; mov esi,labellen-labelt ; text length |
; int 0x40 |
; CLOSE BUTTON |
; mov eax,8 ; function 8 : define and draw button |
; mov ebx,(300-19)*65536+12 ; [x start] *65536 + [x size] |
; mov ecx,5*65536+12 ; [y start] *65536 + [y size] |
; mov edx,1 ; button id |
; mov esi,0x5599cc ; button color RRGGBB |
; int 0x40 |
draw_text: |
mov ebx,25*65536+35 ; draw info text with function 4 |
mov ecx,0xffffff |
mov edx,text |
mov esi,40 |
mov edi,20 |
newline: |
mov eax,4 |
int 0x40 |
add ebx,10 |
add edx,esi |
dec edi |
jne newline |
mov eax,12 |
mov ebx,2 |
int 0x40 |
ret |
; DATA AREA |
wcolor dd 0x13000000 |
labelt db 'INFRARED RECEIVER FOR IRMAN IN COM 1',0 |
text: |
I_END: |
/programs/develop/examples/ir/trunk/macros.inc |
---|
0,0 → 1,267 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
/programs/develop/examples/md5/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm md5.asm md5 |
@pause |
/programs/develop/examples/md5/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm md5.asm md5 |
@pause |
/programs/develop/examples/md5/trunk/md5.asm |
---|
0,0 → 1,445 |
; ਬ¥à ॠ«¨§ 樨 £¥¥à â®à MD5 - å¥è |
; |
; MD5 Generator |
; |
; ¢â®à: Hex |
; ©â: www.mestack.narod.ru |
; ¤¥ï, ॠ«¨§ æ¨ï ¨ ®â« ¤ª . |
; |
; ¢â®à: Halyavin |
; ©â: www.shade.msu.ru/~msu-se/home.html |
; ®à ¡®âª , ®â« ¤ª ¨ ®¯â¨¬¨§ æ¨ï. |
; |
; ®¬¯¨«¨àã¥âìáï Fasm'®¬ ¤«ï ¥ãíâ |
include 'lang.inc' |
macro diff16 title,l2 |
{ |
local s,d,l1 |
s = l2 |
display title,': 0x' |
repeat 8 |
d = 48 + s shr ((8-%) shl 2) and $0F |
if d > 57 |
d = d + 65-57-1 |
end if |
display d |
end repeat |
display 13,10 |
} |
use32 |
org 0x0 |
db 'MENUET01' ; 8-¡ ©âë© ¨¤¥â¨ä¨ª â®à MenuetOS |
dd 0x01 ; ¢¥àá¨ï § £®«®¢ª (¢á¥£¤ 1) |
dd START ; ¤à¥á ¯¥à¢®© ª®¬ ¤ë |
dd I_END ; à §¬¥à ¯à®£à ¬¬ë |
dd 0x100000 ; ª®«¨ç¥á⢮ ¯ ¬ï⨠|
dd 0x100000 ; ¤à¥á ¢¥àè¨ë áâíª |
dd 0x0 ; ¤à¥á ¡ãä¥à ¤«ï ¯ à ¬¥â஢ (¥ ¨á¯®«ì§ã¥âáï) |
dd 0x0 ; § १¥à¢¨à®¢ ® |
START: ; ç «® ¢ë¯®«¥¨ï ¯à®£à ¬¬ë |
call draw_window ; ¯¥à¢ ¯¥à¥à¨á㥬 ®ª® |
still: |
mov eax,23 ; ¦¨¤ ¥¬ ᮡë⨩ |
mov ebx,1 |
int 0x40 |
cmp eax,1 ; ¯à®á ¯¥à¥à¨á®¢ªã ? |
jz red |
cmp eax,2 ; ¦ â ª« ¢¨è¨ ? |
jz key |
cmp eax,3 ; ¦ â ª®¯ª ? |
jz button |
jmp still |
red: |
call draw_window |
jmp still |
key: |
mov eax,2 |
int 0x40 |
jmp still |
button: |
mov eax,17 |
int 0x40 |
cmp ah,1 ; id ª®¯ª¨ = 1 ? |
jnz noclose |
mov eax,-1 |
int 0x40 |
noclose: |
cmp ah,2 ; ¥¥à¨à®¢ âì? |
je procMD5hash |
jmp still |
procMD5hash: |
; phase I - padding |
mov edi,ptBuffer |
mov eax,[dtBufferLength] |
inc eax |
add edi,eax |
mov byte [edi-1],0x80 |
xor edx,edx |
mov ebx,64 |
div ebx |
neg edx |
add edx,64 |
cmp edx,8 |
jae @f |
add edx,64 |
@@: mov ecx,edx |
xor al,al |
rep stosb |
mov eax,[dtBufferLength] |
inc edx |
add [dtBufferLength],edx |
xor edx,edx |
mov ebx,8 |
mul ebx |
mov [edi-8],eax |
mov [edi-4],edx |
mov edx,[dtBufferLength] |
mov edi,ptBuffer |
; phase II - chaining variables initialization |
mov dword [dtA],067452301h |
mov dword [dtB],0efcdab89h |
mov dword [dtC],098badcfeh |
mov dword [dtD],010325476h |
mov esi,ptMD5Result |
hashloop: |
;diff16 "hashloop",hashloop |
mov eax,[dtA] |
mov [dta],eax |
mov eax,[dtB] |
mov [dtb],eax |
mov eax,[dtC] |
mov [dtc],eax |
mov eax,[dtD] |
mov [dtd],eax |
macro ff dta,dtb,dtc,dtd,data,shift,cc |
{ |
mov eax,dtb |
mov ebx,dtc |
mov ecx,dtd |
and ebx,eax |
not eax |
and eax,ecx |
or eax,ebx |
add eax,dta |
add eax,data |
add eax,cc |
rol eax,shift |
add eax,dtb |
mov dta,eax |
} |
macro gg dta,dtb,dtc,dtd,data,shift,cc |
{ |
mov eax,dtb |
mov ebx,dtc |
mov ecx,dtd |
and eax,ecx |
not ecx |
and ecx,ebx |
or eax,ecx |
add eax,dta |
add eax,data |
add eax,cc |
rol eax,shift |
add eax,dtb |
mov dta,eax |
} |
macro hh dta,dtb,dtc,dtd,data,shift,cc |
{ |
mov eax,dtb |
mov ebx,dtc |
mov ecx,dtd |
xor eax,ebx |
xor eax,ecx |
add eax,dta |
add eax,data |
add eax,cc |
rol eax,shift |
add eax,dtb |
mov dta,eax |
} |
macro ii dta,dtb,dtc,dtd,data,shift,cc |
{ |
mov eax,dtb |
mov ebx,dtc |
mov ecx,dtd |
not ecx |
or eax,ecx |
xor eax,ebx |
add eax,dta |
add eax,data |
add eax,cc |
rol eax,shift |
add eax,dtb |
mov dta,eax |
} |
; round 1 |
ff [dta],[dtb],[dtc],[dtd],dword [edi+00*4],07,0xd76aa478 |
ff [dtd],[dta],[dtb],[dtc],dword [edi+01*4],12,0xe8c7b756 |
ff [dtc],[dtd],[dta],[dtb],dword [edi+02*4],17,0x242070db |
ff [dtb],[dtc],[dtd],[dta],dword [edi+03*4],22,0xc1bdceee |
ff [dta],[dtb],[dtc],[dtd],dword [edi+04*4],07,0xf57c0faf |
ff [dtd],[dta],[dtb],[dtc],dword [edi+05*4],12,0x4787c62a |
ff [dtc],[dtd],[dta],[dtb],dword [edi+06*4],17,0xa8304613 |
ff [dtb],[dtc],[dtd],[dta],dword [edi+07*4],22,0xfd469501 |
ff [dta],[dtb],[dtc],[dtd],dword [edi+08*4],07,0x698098d8 |
ff [dtd],[dta],[dtb],[dtc],dword [edi+09*4],12,0x8b44f7af |
ff [dtc],[dtd],[dta],[dtb],dword [edi+10*4],17,0xffff5bb1 |
ff [dtb],[dtc],[dtd],[dta],dword [edi+11*4],22,0x895cd7be |
ff [dta],[dtb],[dtc],[dtd],dword [edi+12*4],07,0x6b901122 |
ff [dtd],[dta],[dtb],[dtc],dword [edi+13*4],12,0xfd987193 |
ff [dtc],[dtd],[dta],[dtb],dword [edi+14*4],17,0xa679438e |
ff [dtb],[dtc],[dtd],[dta],dword [edi+15*4],22,0x49b40821 |
; round 2 |
gg [dta],[dtb],[dtc],[dtd],dword [edi+01*4],05,0xf61e2562 |
gg [dtd],[dta],[dtb],[dtc],dword [edi+06*4],09,0xc040b340 |
gg [dtc],[dtd],[dta],[dtb],dword [edi+11*4],14,0x265e5a51 |
gg [dtb],[dtc],[dtd],[dta],dword [edi+00*4],20,0xe9b6c7aa |
gg [dta],[dtb],[dtc],[dtd],dword [edi+05*4],05,0xd62f105d |
gg [dtd],[dta],[dtb],[dtc],dword [edi+10*4],09,0x02441453 |
gg [dtc],[dtd],[dta],[dtb],dword [edi+15*4],14,0xd8a1e681 |
gg [dtb],[dtc],[dtd],[dta],dword [edi+04*4],20,0xe7d3fbc8 |
gg [dta],[dtb],[dtc],[dtd],dword [edi+09*4],05,0x21e1cde6 |
gg [dtd],[dta],[dtb],[dtc],dword [edi+14*4],09,0xc33707d6 |
gg [dtc],[dtd],[dta],[dtb],dword [edi+03*4],14,0xf4d50d87 |
gg [dtb],[dtc],[dtd],[dta],dword [edi+08*4],20,0x455a14ed |
gg [dta],[dtb],[dtc],[dtd],dword [edi+13*4],05,0xa9e3e905 |
gg [dtd],[dta],[dtb],[dtc],dword [edi+02*4],09,0xfcefa3f8 |
gg [dtc],[dtd],[dta],[dtb],dword [edi+07*4],14,0x676f02d9 |
gg [dtb],[dtc],[dtd],[dta],dword [edi+12*4],20,0x8d2a4c8a |
; round 3 |
hh [dta],[dtb],[dtc],[dtd],dword [edi+05*4],04,0xfffa3942 |
hh [dtd],[dta],[dtb],[dtc],dword [edi+08*4],11,0x8771f681 |
hh [dtc],[dtd],[dta],[dtb],dword [edi+11*4],16,0x6d9d6122 |
hh [dtb],[dtc],[dtd],[dta],dword [edi+14*4],23,0xfde5380c |
hh [dta],[dtb],[dtc],[dtd],dword [edi+01*4],04,0xa4beea44 |
hh [dtd],[dta],[dtb],[dtc],dword [edi+04*4],11,0x4bdecfa9 |
hh [dtc],[dtd],[dta],[dtb],dword [edi+07*4],16,0xf6bb4b60 |
hh [dtb],[dtc],[dtd],[dta],dword [edi+10*4],23,0xbebfbc70 |
hh [dta],[dtb],[dtc],[dtd],dword [edi+13*4],04,0x289b7ec6 |
hh [dtd],[dta],[dtb],[dtc],dword [edi+00*4],11,0xeaa127fa |
hh [dtc],[dtd],[dta],[dtb],dword [edi+03*4],16,0xd4ef3085 |
hh [dtb],[dtc],[dtd],[dta],dword [edi+06*4],23,0x04881d05 |
hh [dta],[dtb],[dtc],[dtd],dword [edi+09*4],04,0xd9d4d039 |
hh [dtd],[dta],[dtb],[dtc],dword [edi+12*4],11,0xe6db99e5 |
hh [dtc],[dtd],[dta],[dtb],dword [edi+15*4],16,0x1fa27cf8 |
hh [dtb],[dtc],[dtd],[dta],dword [edi+02*4],23,0xc4ac5665 |
; round 4 |
ii [dta],[dtb],[dtc],[dtd],dword [edi+00*4],06,0xf4292244 |
ii [dtd],[dta],[dtb],[dtc],dword [edi+07*4],10,0x432aff97 |
ii [dtc],[dtd],[dta],[dtb],dword [edi+14*4],15,0xab9423a7 |
ii [dtb],[dtc],[dtd],[dta],dword [edi+05*4],21,0xfc93a039 |
ii [dta],[dtb],[dtc],[dtd],dword [edi+12*4],06,0x655b59c3 |
ii [dtd],[dta],[dtb],[dtc],dword [edi+03*4],10,0x8f0ccc92 |
ii [dtc],[dtd],[dta],[dtb],dword [edi+10*4],15,0xffeff47d |
ii [dtb],[dtc],[dtd],[dta],dword [edi+01*4],21,0x85845dd1 |
ii [dta],[dtb],[dtc],[dtd],dword [edi+08*4],06,0x6fa87e4f |
ii [dtd],[dta],[dtb],[dtc],dword [edi+15*4],10,0xfe2ce6e0 |
ii [dtc],[dtd],[dta],[dtb],dword [edi+06*4],15,0xa3014314 |
ii [dtb],[dtc],[dtd],[dta],dword [edi+13*4],21,0x4e0811a1 |
ii [dta],[dtb],[dtc],[dtd],dword [edi+04*4],06,0xf7537e82 |
ii [dtd],[dta],[dtb],[dtc],dword [edi+11*4],10,0xbd3af235 |
ii [dtc],[dtd],[dta],[dtb],dword [edi+02*4],15,0x2ad7d2bb |
ii [dtb],[dtc],[dtd],[dta],dword [edi+09*4],21,0xeb86d391 |
mov eax,[dta] |
add [dtA],eax |
mov eax,[dtb] |
add [dtB],eax |
mov eax,[dtc] |
add [dtC],eax |
mov eax,[dtd] |
add [dtD],eax |
add edi,64 |
sub edx,64 |
jnz hashloop |
; phase IV - results |
mov ecx,4 |
mov esi,ptMD5Result |
@@: mov eax,[esi] |
xchg al,ah |
rol eax,16 |
xchg al,ah |
mov [esi],eax |
add esi,4 |
loop @b |
translate: |
;diff16 "translate",translate |
mov esi,ptMD5Result-5 |
mov edi,hexresult |
mov ecx,16 |
@@: |
test ecx,3 |
jnz .nojmp |
add esi,8 |
.nojmp: |
xor eax,eax |
mov al,byte [esi] |
mov edx,eax |
shr eax,4 |
mov bl,byte [table+eax] |
mov [edi],bl |
inc edi |
and edx,15 |
mov bl,byte [table+edx] |
mov [edi],bl |
dec esi |
inc edi |
loop @b |
mov esi,hexresult |
mov [text], esi |
mov eax,32 |
mov [textlen], eax |
call draw_window |
jmp still |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
int 0x40 |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,100*65536+230 ; [x start] *65536 + [x size] |
mov ecx,60*65536+100 ; [y start] *65536 + [y size] |
mov edx,0x03ffffff ; color of work area RRGGBB |
mov esi,0x80aabbcc ; color of grab bar RRGGBB,8->color gl |
mov edi,0x00aabbcc ; 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,0x00ffffff ; color of text RRGGBB |
mov edx,labeltext ; pointer to text beginning |
mov esi,lte-labeltext ; text length |
int 0x40 |
; ¨á㥬 ª®¯ªã ¤«ï £¥¥à 樨 |
mov eax,8 ; function 8 : define and draw button |
mov ebx,20*65536+80 ; [x start] *65536 + [x size] |
mov ecx,34*65536+14 ; [y start] *65536 + [y size] |
mov edx,2 ; button id |
mov esi,0x5588dd ; button color RRGGBB |
int 0x40 |
; §¢ ¨¥ ª®¯ªã |
mov eax,4 ; function 4 : write text to window |
mov ebx,23*65536+38 ; [x start] *65536 + [y start] |
mov ecx,0x000000 ; color of text RRGGBB |
mov edx,gen_txt ; pointer to text beginning |
mov esi,gen_len-gen_txt ; text length |
int 0x40 |
mov eax,4 ; draw info text with function 4 |
mov ebx,20*65536+70 |
mov ecx,0x000000 |
mov edx,[text] |
xor eax,eax |
mov al, [textlen] |
mov esi,eax |
mov eax,4 |
int 0x40 |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
ret |
;¡« áâì ¤ ëå |
labeltext: db 'MD5 Generator' |
lte: |
text: dd 0 |
textlen: dd 0 |
gen_txt: db '£¥¥à¨à®¢ âì' |
gen_len: |
InputMD5Rez: dd 0 |
InputMD5Rezlen: |
ptBuffer: db '123' ; ¬¥¨âì £¥¥à¨à㥬®¥ á«®¢® |
rb 61 |
dtBufferLength: dd 3 ; §¬¥à ptBuffer |
ptMD5Result: |
dtA: dd 0 |
dtB: dd 0 |
dtC: dd 0 |
dtD: dd 0 |
dta: dd 0 |
dtb: dd 0 |
dtc: dd 0 |
dtd: dd 0 |
x: dd 0 |
s: dd 0 |
t: dd 0 |
table: db '0123456789abcdef' |
hexresult db 32 |
I_END: |
/programs/develop/examples/rtdata/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm rtdata.asm rtdata |
@pause |
/programs/develop/examples/rtdata/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm rtdata.asm rtdata |
@pause |
/programs/develop/examples/rtdata/trunk/macros.inc |
---|
0,0 → 1,266 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
/programs/develop/examples/rtdata/trunk/rtdata.asm |
---|
0,0 → 1,235 |
; |
; COMMUNICATING WITH MODEM: PORTS & IRQ |
; |
; Compile with FASM for Menuet |
; |
include "lang.inc" |
include "macros.inc" |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; start of code |
dd I_END ; size of image |
dd 0x1000 ; memory for app |
dd 0x1000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Icon |
START: ; start of execution |
mov eax,45 ; reserve irq 4 |
mov ebx,0 |
mov ecx,4 |
int 0x40 |
mov eax,46 ; reserve ports 0x3f8-0x3ff |
mov ebx,0 |
mov ecx,0x3f8 |
mov edx,0x3ff |
int 0x40 |
mov eax,44 ; read these ports at interrupt/irq 4 |
mov ebx,irqtable |
mov ecx,4 |
int 0x40 |
mov eax,40 ; enable event for interrupt/irq 4 |
mov ebx,10000b shl 16 + 111b |
int 0x40 |
call program_com1 |
call draw_window |
still: |
mov eax,10 ; wait here for event |
int 0x40 |
cmp eax,1 ; redraw request ? |
je red |
cmp eax,2 ; key in buffer ? |
je key |
cmp eax,3 ; button in buffer ? |
je button |
cmp eax,16+4 ; data read by interrupt ? |
je irq4 |
jmp still |
red: ; redraw |
call draw_window |
jmp still |
key: ; key |
mov eax,2 ; just read it and ignore |
int 0x40 |
mov al,ah |
mov dx,0x3f8 |
out dx,al |
jmp still |
button: ; button |
or eax,-1 ; close this program |
int 0x40 |
irq4: |
mov eax,42 |
mov ebx,4 |
int 0x40 |
; eax = number of bytes left |
; ecx = 0 success, =1 fail |
; bl = byte |
inc [pos] |
and [pos],31 |
mov eax,[pos] |
mov [string+eax], bl |
call draw_string |
jmp still |
baudrate_9600 equ 12 |
baudrate_57600 equ 2 |
program_com1: |
mov dx,0x3f8+3 |
mov al,0x80 |
out dx,al |
mov dx,0x3f8+1 |
mov al,0x00 |
out dx,al |
mov dx,0x3f8+0 |
mov al,baudrate_9600 |
out dx,al |
mov dx,0x3f8+3 |
mov al,0x3 |
out dx,al |
mov dx,0x3f8+4 |
mov al,0xb |
out dx,al |
mov dx,0x3f8+1 |
mov al,0x1 |
out dx,al |
ret |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax, 48 |
mov ebx, 3 |
mov ecx, sc |
mov edx, sizeof.system_colors |
int 0x40 |
mov eax, 12 ; function 12:tell os about windowdraw |
mov ebx, 1 ; 1, start of draw |
int 0x40 |
; DRAW WINDOW |
mov eax, 0 ; function 0 : define and draw window |
mov ebx, 100*65536+250 ; [x start] *65536 + [x size] |
mov ecx, 100*65536+85 ; [y start] *65536 + [y size] |
mov edx, [sc.work] |
or edx, 0x03000000 ; color of work area RRGGBB,8->color gl |
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, [sc.grab_text] |
or ecx, 0x10000000 ; font 1 & color ( 0xF0RRGGBB ) |
mov edx, header ; pointer to text beginning |
mov esi, header.len ; text length |
int 0x40 |
mov eax, 4 ; draw text |
mov ebx, 20*65536+33 |
mov ecx, [sc.work_text] |
mov edx, text+4 |
.nextstr: |
mov esi, [edx-4] |
test esi, 0xFF000000 |
jnz .finstr |
int 0x40 |
add edx, esi |
add edx, 4 |
add ebx, 10 |
jmp .nextstr |
.finstr: |
call draw_string |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
ret |
draw_string: |
mov eax, 4 |
mov ebx, 20*65536+65 |
mov ecx, [sc.work_text] |
mov edx, string |
mov esi, 32 |
int 0x40 |
ret |
; DATA AREA |
if lang eq ru |
text mstr " .",\ |
" ",\ |
" IRQ4 ." |
header: |
db ' COM1' |
.len = $ - header |
else |
text mstr "TYPED CHARACTERS ARE SENT TO MODEM.",\ |
"DATA FROM MODEM IS READ BY IRQ4",\ |
"INTERRUPT AND DISPLAYED BELOW." |
header: |
db 'MODEM AT COM1' |
.len = $ - header |
end if |
pos dd 0x0 |
irqtable: |
; port ; 1=byte, 2=word |
dd 0x3f8 +0x01000000 ; read byte from port 0x3f8 at interrupt/irq 4 |
dd 0x0 ; no more ports ( max 15 ) to read |
I_END: |
string rb 32 |
sc system_colors |