/programs/network/airc/trunk/airc.asm |
---|
0,0 → 1,2359 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; IRC CLIENT for MenuetOS ;; |
;; ;; |
;; License: GPL / See file COPYING for details ;; |
;; Copyright 2004 (c) Ville Turjanmaa ;; |
;; ;; |
;; Compile with FASM for Menuet ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
version equ '0.3' |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; required os |
dd START ; program start |
dd I_END ; program image size |
dd 0x100000 ; required amount of memory |
dd 0x100000 |
dd 0,0 |
include "lang.inc" |
include "macros.inc" |
irc_server_ip db 192,168,1,1 |
user_nick dd 4 ; length |
db 'airc ' ; string |
user_real_name dd 8 ; length |
db 'Joe User ' ; string |
START: ; start of execution |
mov eax,40 |
mov ebx,10000111b |
int 0x40 |
mov edi,I_END |
mov ecx,60*120 |
mov eax,32 |
cld |
rep stosb |
mov eax,[rxs] |
imul eax,11 |
mov [pos],eax |
mov ebp,0 |
mov edx,I_END |
call draw_window ; at first, draw the window |
still: |
inc [cursor_on_off] |
mov eax,5 |
mov ebx,1 |
int 0x40 |
mov eax,11 ; wait here for event |
int 0x40 |
call print_status |
cmp eax,1 ; redraw |
je redraw |
cmp eax,2 ; key |
je main_window_key |
cmp eax,3 ; button |
je button |
cmp [I_END+120*60],byte 1 |
jne no_main_update |
mov [I_END+120*60],byte 0 |
mov edx,I_END |
call draw_channel_text |
no_main_update: |
call read_incoming_data |
call send_data_to_server |
test [cursor_on_off],0x3f |
jnz nopri |
inc [blink] |
call blink_cursor |
call print_channel_list |
nopri: |
jmp still |
redraw: ; redraw |
call draw_window |
jmp still |
button: ; button |
mov eax,17 ; get id |
int 0x40 |
cmp ah,1 ; close program |
jne noclose |
mov eax,-1 |
int 0x40 |
noclose: |
call socket_commands |
jmp still |
print_status: |
pusha |
mov eax,53 |
mov ebx,6 |
mov ecx,[socket] |
int 0x40 |
mov [status],eax |
cmp [old_status],eax |
je nopr |
mov [old_status],eax |
push eax |
mov eax,13 |
mov ebx,450*65536+30 |
mov ecx,231*65536+10 |
mov edx,0xffffff |
int 0x40 |
pop ecx |
mov eax,47 |
mov ebx,2*65536 |
mov edx,450*65536+231 |
mov esi,0x000000 |
int 0x40 |
nopr: |
popa |
ret |
status dd 0 |
old_status dd 0 |
socket_commands: |
cmp ah,22 ; open socket |
jnz tst3 |
mov eax,3 |
int 0x40 |
mov ecx,eax |
mov eax,53 |
mov ebx,5 |
mov edx,6667 |
mov esi,dword [irc_server_ip] |
mov edi,1 |
int 0x40 |
mov [socket], eax |
ret |
tst3: |
cmp ah,23 ; write userinfo |
jnz tst4 |
mov eax,53 ; user |
mov ebx,7 |
mov ecx,[socket] |
mov edx,string0l-string0 |
mov esi,string0 |
int 0x40 |
mov eax,53 ; |
mov ebx,7 |
mov ecx,[socket] |
mov edx,[user_real_name] |
mov esi,user_real_name+4 |
int 0x40 |
mov eax,53 ; |
mov ebx,7 |
mov ecx,[socket] |
mov edx,2 |
mov esi,line_feed |
int 0x40 |
mov eax,5 |
mov ebx,10 |
int 0x40 |
mov eax,53 ; nick |
mov ebx,7 |
mov ecx,[socket] |
mov edx,string1l-string1 |
mov esi,string1 |
int 0x40 |
mov eax,53 ; |
mov ebx,7 |
mov ecx,[socket] |
mov edx,[user_nick] |
mov esi,user_nick+4 |
int 0x40 |
mov eax,53 ; |
mov ebx,7 |
mov ecx,[socket] |
mov edx,2 |
mov esi,line_feed |
int 0x40 |
ret |
line_feed: db 13,10 |
tst4: |
cmp ah,24 ; close socket |
jnz no_24 |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
int 0x40 |
ret |
no_24: |
ret |
main_window_key: |
mov eax,2 |
int 0x40 |
shr eax,8 |
cmp eax,8 |
jne no_bks2 |
cmp [xpos],0 |
je still |
dec [xpos] |
call print_entry |
jmp still |
no_bks2: |
cmp eax,20 |
jbe no_character2 |
mov ebx,[xpos] |
mov [send_string+ebx],al |
inc [xpos] |
cmp [xpos],80 |
jb noxposdec |
mov [xpos],79 |
noxposdec: |
call print_entry |
jmp still |
no_character2: |
cmp eax,13 |
jne no_send |
cmp [xpos],0 |
je no_send2 |
cmp [send_string],byte '/' ; server command |
jne no_send2 |
mov [send_to_server],1 |
jmp still |
no_send2: |
jmp still |
print_channel_list: |
pusha |
mov eax,13 |
mov ebx,415*65536+6*13 |
mov ecx,27*65536+12*10 |
mov edx,0xffffff |
int 0x40 |
mov eax,4 |
mov ebx,415*65536+27 |
mov ecx,[index_list_1] |
mov edx,channel_list+32 |
newch: |
movzx esi,byte [edx+31] |
and esi,0x1f |
int 0x40 |
add edx,32 |
add ebx,12 |
cmp edx,channel_list+32*10 |
jbe newch |
no_channel_list: |
popa |
ret |
print_user_list: |
pusha |
newtry: |
mov edx,ebp |
imul edx,120*80 |
add edx,120*60+8+I_END |
cmp [edx],byte 1 |
je nonp |
mov edx,ebp |
imul edx,120*80 |
add edx,120*70+I_END |
mov edi,edx |
mov eax,[edx-8] |
mov ebx,[edx-4] |
add ebx,edx |
sub ebx,3 |
inc eax |
dec edx |
newnss: |
inc edx |
dec eax |
jz startuu |
asdf: |
cmp [edx],word ' ' |
jne nodouble |
inc edx |
nodouble: |
cmp [edx],byte ' ' |
je newnss |
inc edx |
cmp edx,ebx |
jbe asdf |
dec dword [edi-8] |
popa |
ret |
startuu: |
cmp [edx],byte ' ' |
jne startpr |
inc edx |
startpr: |
pusha |
mov eax,13 |
mov ebx,415*65536+6*13 |
mov ecx,27*65536+12*10 |
mov edx,0xffffff |
int 0x40 |
popa |
mov eax,4 |
mov ebx,415*65536+27 |
mov ebp,0 |
newuser: |
mov esi,0 |
newusers: |
cmp [edx+esi],byte ' ' |
je do_print |
inc esi |
cmp esi,20 |
jbe newusers |
do_print: |
mov ecx,[index_list_1] |
cmp [edx],byte '@' |
jne no_op |
mov ecx,[index_list_2] |
no_op: |
int 0x40 |
inc ebp |
cmp ebp,10 |
je nonp |
add ebx,12 |
add edx,esi |
inc edx |
cmp [edx],byte ' ' |
jne newuser |
inc edx |
jmp newuser |
nonp: |
popa |
ret |
start_user_list_at dd 0x0 |
send_data_to_server: |
pusha |
cmp [send_to_server],1 |
jne sdts_ret |
mov eax,[xpos] |
mov [send_string+eax+0],byte 13 |
mov [send_string+eax+1],byte 10 |
mov eax,[rxs] |
imul eax,11 |
mov [pos],eax |
mov eax,[send_to_channel] |
imul eax,120*80 |
add eax,I_END |
mov [text_start],eax |
cmp [send_string],byte '/' ; server command |
je server_command |
mov bl,13 |
call print_character |
mov bl,10 |
call print_character |
mov bl,'<' |
call print_character |
mov esi,user_nick+4 |
mov ecx,[user_nick] |
newnp: |
mov bl,[esi] |
call print_character |
inc esi |
loop newnp |
mov bl,'>' |
call print_character |
mov bl,' ' |
call print_character |
mov ecx,[xpos] |
mov esi,send_string |
newcw: |
mov bl,[esi] |
call print_character |
inc esi |
loop newcw |
mov eax,dword [send_to_channel] |
shl eax,5 |
add eax,channel_list |
mov esi,eax |
mov edi,send_string_header+8 |
movzx ecx,byte [eax+31] |
cld |
rep movsb |
mov [edi],word ' :' |
mov esi, send_string_header |
mov edx,10 |
movzx ebx,byte [eax+31] |
add edx,ebx |
mov eax, 53 ; write channel |
mov ebx, 7 |
mov ecx, [socket] |
int 0x40 |
mov esi,send_string |
mov edx,[xpos] |
inc edx |
mov eax, 53 ; write message |
mov ebx, 7 |
mov ecx, [socket] |
int 0x40 |
jmp send_done |
server_command: |
cmp [send_string+1],dword 'anic' |
jne no_set_nick |
mov ecx,[xpos] |
sub ecx,7 |
mov [user_nick],ecx |
mov esi,send_string+7 |
mov edi,user_nick+4 |
cld |
rep movsb |
pusha |
mov edi,text+70*1+15 |
mov eax,32 |
mov ecx,15 |
cld |
rep stosb |
popa |
mov esi,user_nick+4 |
mov edi,text+70*1+15 |
mov ecx,[user_nick] |
cld |
rep movsb |
call draw_window |
mov [xpos],0 |
mov [send_to_server],0 |
popa |
ret |
no_set_nick: |
cmp [send_string+1],dword 'area' |
jne no_set_real_name |
mov ecx,[xpos] |
sub ecx,7 |
mov [user_real_name],ecx |
mov esi,send_string+7 |
mov edi,user_real_name+4 |
cld |
rep movsb |
pusha |
mov edi,text+70*0+15 |
mov eax,32 |
mov ecx,15 |
cld |
rep stosb |
popa |
mov esi,user_real_name+4 |
mov edi,text+70*0+15 |
mov ecx,[xpos] |
sub ecx,7 |
cld |
rep movsb |
call draw_window |
mov [xpos],0 |
mov [send_to_server],0 |
popa |
ret |
no_set_real_name: |
cmp [send_string+1],dword 'aser' |
jne no_set_server |
pusha |
mov edi,irc_server_ip |
mov esi,send_string+7 |
mov eax,0 |
mov edx,[xpos] |
add edx,send_string-1 |
newsip: |
cmp [esi],byte '.' |
je sipn |
cmp esi,edx |
jg sipn |
movzx ebx,byte [esi] |
inc esi |
imul eax,10 |
sub ebx,48 |
add eax,ebx |
jmp newsip |
sipn: |
mov [edi],al |
xor eax,eax |
inc esi |
cmp esi,send_string+30 |
jg sipnn |
inc edi |
cmp edi,irc_server_ip+3 |
jbe newsip |
sipnn: |
popa |
mov ecx,[xpos] |
sub ecx,7 |
pusha |
mov edi,text+70*2+15 |
mov eax,32 |
mov ecx,15 |
cld |
rep stosb |
popa |
mov esi,send_string+7 |
mov edi,text+70*2+15 |
cld |
rep movsb |
call draw_window |
mov [xpos],0 |
mov [send_to_server],0 |
popa |
ret |
no_set_server: |
cmp [send_string+1],dword 'quer' |
jne no_query_create |
mov edi,I_END+120*80 |
mov eax,1 ; create channel window - search for empty slot |
newse2: |
mov ebx,eax |
shl ebx,5 |
cmp dword [channel_list+ebx],dword ' ' |
je free_found2 |
add edi,120*80 |
inc eax |
cmp eax,[max_windows] |
jb newse2 |
free_found2: |
mov edx,send_string+7 |
mov ecx,[xpos] |
sub ecx,7 |
mov [channel_list+ebx+31],cl |
call create_channel_name |
push edi |
push eax |
mov [edi+120*60+8],byte 1 ; query window |
mov eax,32 |
mov ecx,120*60 |
cld |
rep stosb |
pop eax |
pop edi |
; eax has the free position |
mov [thread_screen],edi |
call create_channel_window |
mov [xpos],0 |
mov [send_to_server],0 |
popa |
ret |
no_query_create: |
mov esi, send_string+1 |
mov edx, [xpos] |
add edx,1 |
mov eax, 53 ; write server command |
mov ebx, 7 |
mov ecx, [socket] |
int 0x40 |
send_done: |
mov [xpos],0 |
mov [send_to_server],0 |
cmp [send_string+1],dword 'quit' |
jne no_quit_server |
mov eax,5 |
mov ebx,200 |
int 0x40 |
mov eax, 53 ; close socket |
mov ebx, 8 |
mov ecx, [socket] |
int 0x40 |
mov ecx,[max_windows] |
mov edi,I_END |
newclose: |
mov [edi+120*60+4],byte 1 |
add edi,120*80 |
loop newclose |
popa |
ret |
no_quit_server: |
sdts_ret: |
popa |
ret |
read_incoming_data: |
pusha |
read_new_byte: |
call read_incoming_byte |
cmp ecx,-1 |
je no_data_in_buffer |
cmp bl,10 |
jne no_start_command |
mov [cmd],1 |
no_start_command: |
cmp bl,13 |
jne no_end_command |
mov eax,[cmd] |
mov [eax+command-2],byte 0 |
call analyze_command |
mov edi,command |
mov ecx,250 |
mov eax,0 |
cld |
rep stosb |
mov [cmd],0 |
no_end_command: |
mov eax,[cmd] |
cmp eax,512 |
jge still |
mov [eax+command-2],bl |
inc [cmd] |
jmp read_new_byte |
no_data_in_buffer: |
popa |
ret |
create_channel_name: |
pusha |
search_first_letter: |
cmp [edx],byte ' ' |
jne first_letter_found |
inc edx |
jmp search_first_letter |
first_letter_found: |
mov esi,edx |
mov edi,channel_list |
add edi,ebx |
mov ecx,30 |
xor eax,eax |
newcase: |
mov al,[esi] |
cmp eax,'a' |
jb nocdec |
cmp eax,'z' |
jg nocdec |
sub al,97-65 |
nocdec: |
mov [edi],al |
inc esi |
inc edi |
loop newcase |
popa |
ret |
create_channel_window: |
pusha |
mov [cursor_on_off],0 |
mov [thread_nro],eax |
mov eax,51 |
mov ebx,1 |
mov ecx,channel_thread |
mov edx,[thread_stack] |
int 0x40 |
mov eax,5 |
mov ebx,10 |
int 0x40 |
add [thread_stack],0x4000 |
add [thread_screen],120*80 |
popa |
ret |
print_entry: |
pusha |
mov eax,13 |
mov ebx,8*65536+6*80 |
mov ecx,151*65536+13 |
mov edx,0xffffff |
int 0x40 |
mov eax,4 |
mov ebx,8*65536+154 |
mov ecx,0x000000 |
mov edx,send_string |
mov esi,[xpos] |
int 0x40 |
popa |
ret |
blink dd 0x0 |
blink_cursor: |
pusha |
mov eax,9 |
mov ebx,0xe0000 |
mov ecx,-1 |
int 0x40 |
mov edx,[blink] |
and edx,1 |
sub edx,1 |
and edx,0xffffff |
; mov edx,0 |
cmp ax,word [0xe0000+4] |
jne no_blink |
call print_entry |
mov ebx,[xpos] |
imul ebx,6 |
add ebx,8 |
mov cx,bx |
shl ebx,16 |
mov bx,cx |
mov ecx,151*65536+163 |
mov eax,38 |
int 0x40 |
popa |
ret |
no_blink: |
mov eax,13 |
mov ebx,8*65536+6*60 |
mov ecx,151*65536+13 |
mov edx,0xffffff |
int 0x40 |
popa |
ret |
set_channel: |
pusha |
; UPPER / LOWER CASE CHECK |
mov esi,eax |
mov edi,channel_temp |
mov ecx,40 |
xor eax,eax |
newcase2: |
mov al,[esi] |
cmp eax,'#' |
jb newcase_over2 |
cmp eax,'a' |
jb nocdec2 |
cmp eax,'z' |
jg nocdec2 |
sub al,97-65 |
nocdec2: |
mov [edi],al |
inc esi |
inc edi |
loop newcase2 |
newcase_over2: |
sub edi,channel_temp |
mov [channel_temp_length],edi |
mov eax,channel_temp |
mov [text_start],I_END+120*80 |
mov ebx,channel_list+32 |
mov eax,[eax] |
mov edx,[channel_temp_length] |
stcl1: |
cmp dl,[ebx+31] |
jne notfound |
pusha |
xor eax,eax |
xor edx,edx |
mov ecx,0 |
stc4: |
mov dl,[ebx+ecx] |
mov al,[channel_temp+ecx] |
cmp eax,edx |
jne notfound2 |
inc ecx |
cmp ecx,[channel_temp_length] |
jb stc4 |
popa |
jmp found |
notfound2: |
popa |
notfound: |
add [text_start],120*80 |
add ebx,32 |
cmp ebx,channel_list+19*32 |
jb stcl1 |
mov [text_start],I_END |
found: |
popa |
ret |
channel_temp: times 100 db 0 |
channel_temp_length dd 0x0 |
print_nick: |
pusha |
mov eax,command+1 |
mov dl,'!' |
call print_text |
popa |
ret |
analyze_command: |
pusha |
mov [text_start],I_END |
mov ecx,[rxs] |
imul ecx,11 |
mov [pos],ecx |
mov bl,13 |
; call print_character |
mov bl,10 |
; call print_character |
mov ecx,[cmd] |
sub ecx,2 |
mov esi,command+0 |
newcmdc: |
mov bl,[esi] |
; call print_character |
inc esi |
loop newcmdc |
mov edx,I_END |
; call draw_channel_text |
cmp [cmd],20 |
jge cmd_len_ok |
mov [cmd],0 |
popa |
ret |
cmd_len_ok: |
cmp [command],dword 'PING' ; ping response |
jne no_ping_responce |
call print_command_to_main |
mov [command],dword 'PONG' |
call print_command_to_main |
mov eax,4 |
mov ebx,100*65536+3 |
mov ecx,0xffffff |
mov edx,command |
mov esi,[cmd] |
mov [command+esi-1],word '**' |
; int 0x40 |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov edx,[cmd] |
sub edx,2 |
and edx,255 |
mov esi,command |
int 0x40 |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov edx,2 |
mov esi,linef |
int 0x40 |
popa |
ret |
linef db 13,10 |
no_ping_responce: |
mov eax,[rxs] |
imul eax,11 |
mov [pos],eax |
mov [command],byte '<' |
mov eax,command |
mov ecx,100 |
new_blank: |
cmp [eax],byte ' ' |
je bl_found |
inc eax |
loop new_blank |
mov eax,50 |
bl_found: |
inc eax |
mov [command_position],eax |
mov esi,eax |
mov edi,irc_command |
mov ecx,8 |
cld |
rep movsb |
cmp [irc_command],'PRIV' ; message to channel |
jne no_privmsg |
; compare nick |
mov eax,[command_position] |
add eax,8 |
call compare_to_nick |
cmp [cresult],0 |
jne no_query_msg |
mov eax,command+1 |
no_query_msg: |
call set_channel |
mov ecx,100 ; [cmd] |
mov eax,command+10 |
acl3: |
cmp [eax],byte ':' |
je acl4 |
inc eax |
loop acl3 |
mov eax,10 |
acl4: |
inc eax |
cmp [eax+1],dword 'ACTI' |
jne no_action |
push eax |
mov eax,action_header_short |
mov dl,0 |
call print_text |
mov eax,command+1 |
mov dl,'!' |
call print_text |
mov bl,' ' |
call print_character |
pop eax |
add eax,8 |
mov dl,0 |
call print_text |
popa |
ret |
no_action: |
push eax |
mov bl,10 |
call print_character |
mov eax,command |
mov dl,'!' |
call print_text |
mov bl,'>' |
call print_character |
mov bl,' ' |
call print_character |
pop eax |
mov dl,0 |
call print_text |
popa |
ret |
no_privmsg: |
cmp [irc_command],'PART' ; channel leave |
jne no_part |
; compare nick |
mov eax,command+1 |
call compare_to_nick |
cmp [cresult],0 |
jne no_close_window |
mov eax,[command_position] |
add eax,5 |
call set_channel |
mov eax,[text_start] |
mov [eax+120*60+4],byte 1 |
popa |
ret |
no_close_window: |
mov eax,[command_position] |
add eax,5 |
call set_channel |
mov eax,action_header_red |
mov dl,0 |
call print_text |
mov eax,command+1 |
mov dl,'!' |
mov cl,' ' |
call print_text |
mov eax,has_left_channel |
mov dl,0 |
call print_text |
mov eax,[command_position] |
add eax,5 |
mov dl,' ' |
call print_text |
popa |
ret |
no_part: |
cmp [irc_command],'JOIN' ; channel join |
jne no_join |
; compare nick |
mov eax,command+1 |
call compare_to_nick |
cmp [cresult],0 |
jne no_new_window |
mov edi,I_END+120*80 |
mov eax,1 ; create channel window - search for empty slot |
newse: |
mov ebx,eax |
shl ebx,5 |
cmp dword [channel_list+ebx],dword ' ' |
je free_found |
add edi,120*80 |
inc eax |
cmp eax,[max_windows] |
jb newse |
free_found: |
mov edx,[command_position] |
add edx,6 |
push eax |
push edx |
mov ecx,0 |
finde: |
inc ecx |
inc edx |
movzx eax,byte [edx] |
cmp eax,'#' |
jge finde |
mov [channel_list+ebx+31],cl |
pop edx |
pop eax |
call create_channel_name |
push edi |
push eax |
mov [edi+120*60+8],byte 0 ; channel window |
mov eax,32 |
mov ecx,120*60 |
cld |
rep stosb |
pop eax |
pop edi |
; eax has the free position |
mov [thread_screen],edi |
call create_channel_window |
no_new_window: |
mov eax,[command_position] |
add eax,6 |
call set_channel |
mov eax,action_header_blue |
mov dl,0 |
call print_text |
mov eax,command+1 |
mov dl,'!' |
mov cl,' ' |
call print_text |
mov eax,joins_channel |
mov dl,0 |
call print_text |
mov eax,[command_position] |
add eax,6 |
mov dl,0 |
call print_text |
popa |
ret |
no_join: |
cmp [irc_command],'NICK' ; nick change |
jne no_nick_change |
mov [text_start],I_END |
add [text_start],120*80 |
new_all_channels3: |
mov eax,action_header_short |
mov dl,0 |
call print_text |
mov eax,command+1 |
mov dl,'!' |
call print_text |
mov eax,is_now_known_as |
mov dl,0 |
call print_text |
mov eax,[command_position] |
add eax,6 |
mov dl,0 |
call print_text |
add [text_start],120*80 |
cmp [text_start],I_END+120*80*20 |
jb new_all_channels3 |
popa |
ret |
no_nick_change: |
cmp [irc_command],'KICK' ; kick |
jne no_kick |
mov [text_start],I_END |
add [text_start],120*80 |
mov eax,[command_position] |
add eax,5 |
call set_channel |
; new_all_channels4: |
mov eax,action_header_short |
mov dl,0 |
call print_text |
mov eax,command+1 |
mov dl,'!' |
call print_text |
mov eax,kicked |
mov dl,0 |
call print_text |
mov eax,[command_position] |
add eax,5 |
mov dl,0 |
call print_text |
; add [text_start],120*80 |
; cmp [text_start],I_END+120*80*20 |
; jb new_all_channels4 |
popa |
ret |
no_kick: |
cmp [irc_command],'QUIT' ; irc quit |
jne no_quit |
mov [text_start],I_END |
add [text_start],120*80 |
new_all_channels2: |
mov eax,action_header_red |
mov dl,0 |
call print_text |
mov eax,command+1 |
mov dl,'!' |
call print_text |
mov eax,has_quit_irc |
mov dl,0 |
call print_text |
add [text_start],120*80 |
cmp [text_start],I_END+120*80*20 |
jb new_all_channels2 |
popa |
ret |
no_quit: |
cmp [irc_command],dword 'MODE' ; channel mode change |
jne no_mode |
mov [text_start],I_END |
add [text_start],120*80 |
mov eax,[command_position] |
add eax,5 |
call set_channel |
new_all_channels: |
mov eax,action_header_short |
mov dl,0 |
call print_text |
call print_nick |
mov eax,sets_mode |
mov dl,0 |
call print_text |
mov eax,[command_position] |
add eax,5 |
mov dl,0 |
call print_text |
; add [text_start],120*80 |
; cmp [text_start],I_END+120*80*20 |
; jb new_all_channels |
popa |
ret |
no_mode: |
cmp [irc_command],dword '353 ' ; channel user names |
jne no_user_list |
mov eax,[command_position] |
finde2: |
inc eax |
cmp [eax],byte '#' |
jne finde2 |
call set_channel |
finde3: |
inc eax |
cmp [eax],byte ':' |
jne finde3 |
pusha |
cmp [user_list_pos],0 |
jne no_clear_user_list |
mov edi,[text_start] |
add edi,120*70 |
mov [edi-8],dword 0 |
mov [edi-4],dword 0 |
mov eax,32 |
mov ecx,1200 |
cld |
rep stosb |
no_clear_user_list: |
popa |
push eax |
mov esi,eax |
inc esi |
mov edi,[text_start] |
add edi,120*70 |
add edi,[user_list_pos] |
mov edx,edi |
mov ecx,command |
add ecx,[cmd] |
sub ecx,[esp] |
sub ecx,3 |
and ecx,0xfff |
cld |
rep movsb |
pop eax |
mov ebx,command |
add ebx,[cmd] |
sub ebx,eax |
sub ebx,2 |
mov [edx+ebx-1],dword ' ' |
add [user_list_pos],ebx |
mov eax,[user_list_pos] |
mov ebx,[text_start] |
add ebx,120*70 |
mov [ebx-4],eax |
popa |
ret |
user_list_pos dd 0x0 |
no_user_list: |
cmp [irc_command],dword '366 ' ; channel user names end |
jne no_user_list_end |
mov [user_list_pos],0 |
popa |
ret |
no_user_list_end: |
mov [command],byte '-' |
call print_command_to_main |
popa |
ret |
cresult db 0 |
compare_to_nick: |
; input : eax = start of compare |
; output : [cresult] = 0 if match, [cresult]=1 if no match |
pusha |
mov esi,eax |
mov edi,0 |
new_nick_compare: |
mov bl,byte [esi] |
mov cl,byte [user_nick+4+edi] |
cmp bl,cl |
jne nonickm |
add esi,1 |
add edi,1 |
cmp edi,[user_nick] |
jb new_nick_compare |
movzx eax,byte [esi] |
cmp eax,40 |
jge nonickm |
popa |
mov [cresult],0 |
ret |
nonickm: |
popa |
mov [cresult],1 |
ret |
print_command_to_main: |
pusha |
mov [text_start],I_END |
mov ecx,[rxs] |
imul ecx,11 |
mov [pos],ecx |
mov bl,13 |
call print_character |
mov bl,10 |
call print_character |
mov ecx,[cmd] |
sub ecx,2 |
mov esi,command |
newcmdc2: |
mov bl,[esi] |
call print_character |
inc esi |
loop newcmdc2 |
mov edx,I_END |
call draw_channel_text |
popa |
ret |
print_text: |
pusha |
mov ecx,command-2 |
add ecx,[cmd] |
ptr2: |
mov bl,[eax] |
cmp bl,dl |
je ptr_ret |
cmp bl,0 |
je ptr_ret |
call print_character |
inc eax |
cmp eax,ecx |
jbe ptr2 |
ptr_ret: |
mov eax,[text_start] |
mov [eax+120*60],byte 1 |
popa |
ret |
print_character: |
pusha |
cmp bl,13 ; line beginning |
jne nobol |
mov ecx,[pos] |
add ecx,1 |
boll1: |
sub ecx,1 |
mov eax,ecx |
xor edx,edx |
mov ebx,[rxs] |
div ebx |
cmp edx,0 |
jne boll1 |
mov [pos],ecx |
jmp newdata |
nobol: |
cmp bl,10 ; line down |
jne nolf |
addx1: |
add [pos],dword 1 |
mov eax,[pos] |
xor edx,edx |
mov ecx,[rxs] |
div ecx |
cmp edx,0 |
jnz addx1 |
mov eax,[pos] |
jmp cm1 |
nolf: |
no_lf_ret: |
cmp bl,15 ; character |
jbe newdata |
mov eax,[irc_data] |
shl eax,8 |
mov al,bl |
mov [irc_data],eax |
mov eax,[pos] |
call draw_data |
mov eax,[pos] |
add eax,1 |
cm1: |
mov ebx,[scroll+4] |
imul ebx,[rxs] |
cmp eax,ebx |
jb noeaxz |
mov esi,[text_start] |
add esi,[rxs] |
mov edi,[text_start] |
mov ecx,ebx |
cld |
rep movsb |
mov esi,[text_start] |
mov ecx,[rxs] |
imul ecx,61 |
add esi,ecx |
mov edi,[text_start] |
mov ecx,[rxs] |
imul ecx,60 |
add edi,ecx |
mov ecx,ebx |
cld |
rep movsb |
mov eax,ebx |
sub eax,[rxs] |
noeaxz: |
mov [pos],eax |
newdata: |
mov eax,[text_start] |
mov [eax+120*60],byte 1 |
popa |
ret |
draw_data: |
pusha |
and ebx,0xff |
cmp bl,0xe4 ; finnish a |
jne noe4 |
mov bl,0xc1 |
noe4: |
cmp bl,0xc4 ; ? |
jne noc4 |
mov bl,0xc9 |
noc4: |
cmp ebx,229 ; swedish a |
jne no_swedish_a |
mov bl,192 |
no_swedish_a: |
add eax,[text_start] |
mov [eax],bl |
popa |
ret |
read_incoming_byte: |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socket] |
int 0x40 |
mov ecx,-1 |
cmp eax,0 |
je no_more_data |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socket] |
int 0x40 |
mov ecx,0 |
no_more_data: |
ret |
draw_window: |
pusha |
mov eax,12 |
mov ebx,1 |
int 0x40 |
mov [old_status],300 |
mov eax,0 ; draw window |
mov ebx,5*65536+499 |
mov ecx,5*65536+345 |
mov edx,[wcolor] |
add edx,0x03ffffff |
mov esi,0x80555599 |
mov edi,0x00ffffff |
int 0x40 |
mov eax,4 ; label |
mov ebx,9*65536+8 |
mov ecx,0x10ffffff |
mov edx,labelt |
mov esi,labellen-labelt |
int 0x40 |
mov eax,8 ; button: open socket |
mov ebx,43*65536+22 |
mov ecx,229*65536+10 |
mov edx,22 |
mov esi,[main_button] |
int 0x40 |
mov eax,8 ; button: send userinfo |
mov ebx,180*65536+22 |
mov ecx,229*65536+10 |
mov edx,23 |
int 0x40 |
mov eax,8 ; button: close socket |
mov ebx,317*65536+22 |
mov ecx,229*65536+10 |
mov edx,24 |
int 0x40 |
mov eax,38 ; line |
mov ebx,5*65536+494 |
mov ecx,148*65536+148 |
mov edx,[main_line] |
int 0x40 |
add ecx,1*65536+1 |
; mov edx,0x5555cc |
; int 0x40 |
mov eax,38 ; line |
mov ebx,5*65536+494 |
mov ecx,166*65536+166 |
int 0x40 |
add ecx,1*65536+1 |
; mov edx,0x5555cc |
; int 0x40 |
mov eax,38 ; line |
mov ebx,410*65536+410 |
mov ecx,22*65536+148 |
int 0x40 |
add ebx,1*65536+1 |
; mov edx,0x5555cc |
; int 0x40 |
mov ebx,25*65536+183 ; info text |
mov ecx,0x000000 |
mov edx,text |
mov esi,70 |
newline: |
mov eax,4 |
int 0x40 |
add ebx,12 |
add edx,70 |
cmp [edx],byte 'x' |
jne newline |
mov edx,I_END ; text from server |
call draw_channel_text |
mov eax,12 |
mov ebx,2 |
int 0x40 |
popa |
ret |
main_line dd 0x000000 |
main_button dd 0x6565cc |
text: |
db ' Real name : Joe User - change with eg /areal Jill User ' |
db ' Nick : AIRC - change with eg /anick Jill ' |
db ' Server : 192.168.1.1 - change with eg /aserv 192.168.1.24 ' |
db ' ' |
db ' 1) Open socket 2) Send userinfo Close socket ' |
db ' ' |
db ' Commands after established connection: ' |
db ' ' |
db ' /join #ChannelName - eg /join #menuet ' |
db ' /part #ChannelName - eg /part #linux ' |
db ' /query Nickname - eg /query Mary ' |
db ' /quit - Quit server and Close socket ' |
db 'x <- END MARKER, DONT DELETE ' |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; |
; CHANNEL THREADS |
; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
channel_thread: |
mov ebp,[thread_nro] |
mov eax,ebp |
shl eax,14 |
add eax,0x80000 |
mov esp,eax |
mov edi,ebp ; clear thread memory |
imul edi,120*80 |
add edi,I_END |
mov ecx,120*80 |
mov eax,32 |
cld |
; rep stosb |
mov edx,[thread_screen] |
call thread_draw_window |
w_t: |
mov esi,ebp |
imul esi,120*80 |
add esi,I_END |
cmp [esi+120*60+4],byte 1 |
jne no_channel_leave |
mov [esi+120*60+4],byte 0 |
mov edi,ebp |
shl edi,5 |
mov dword [channel_list+edi],dword ' ' |
mov byte [channel_list+edi+31],byte 1 |
mov eax,-1 |
int 0x40 |
no_channel_leave: |
call check_mouse |
mov eax,23 |
mov ebx,1 |
int 0x40 |
cmp eax,1 |
jne no_draw_window |
call thread_draw_window |
call draw_channel_text |
call print_user_list |
no_draw_window: |
cmp eax,2 |
je thread_key |
cmp eax,3 |
jne no_end |
mov eax,17 |
int 0x40 |
mov eax,ebp |
imul eax,120*80 |
add eax,I_END |
cmp [eax+120*60+8],byte 0 ; channel window |
je not_close |
mov eax,ebp |
shl eax,5 |
add eax,channel_list |
mov [eax],dword ' ' |
mov [eax+31],byte 1 |
mov eax,-1 |
int 0x40 |
not_close: |
mov [text_start],eax |
mov eax,nocl |
newcc: |
mov bl,[eax] |
call print_character |
inc eax |
cmp [eax],byte 0 |
jne newcc |
call draw_channel_text |
jmp w_t |
nocl: db 13,10,'To exit channel, use PART or QUIT command.',0 |
no_end: |
cmp [edx+120*60],byte 1 |
jne no_update |
mov [edx+120*60],byte 0 |
call draw_channel_text |
no_update: |
test [cursor_on_off],0x3f |
jnz nopri2 |
call blink_cursor |
call print_user_list |
nopri2: |
jmp w_t |
check_mouse: |
pusha |
mov eax,37 |
mov ebx,1 |
int 0x40 |
mov ebx,eax |
shr eax,16 |
and ebx,0xffff |
cmp eax,420 |
jb no_mouse |
cmp eax,494 |
jg no_mouse |
cmp ebx,145 |
jg no_mouse |
cmp ebx,23 |
jb no_mouse |
cmp ebx,100 |
jb no_plus |
mov eax,ebp |
imul eax,120*80 |
add eax,120*70+I_END |
inc dword [eax-8] |
call print_user_list |
mov eax,5 |
mov ebx,8 |
int 0x40 |
jmp no_mouse |
no_plus: |
cmp ebx,80 |
jg no_mouse |
mov eax,ebp |
imul eax,120*80 |
add eax,120*70+I_END |
cmp dword [eax-8],dword 0 |
je no_mouse |
dec dword [eax-8] |
call print_user_list |
mov eax,5 |
mov ebx,8 |
int 0x40 |
no_minus: |
no_mouse: |
popa |
ret |
thread_key: |
mov eax,2 |
int 0x40 |
shr eax,8 |
cmp eax,8 |
jne no_bks |
cmp [xpos],0 |
je w_t |
dec [xpos] |
call print_entry |
jmp w_t |
no_bks: |
cmp eax,20 |
jbe no_character |
mov ebx,[xpos] |
mov [send_string+ebx],al |
inc [xpos] |
cmp [xpos],80 |
jb xpok |
mov [xpos],79 |
xpok: |
call print_entry |
jmp w_t |
no_character: |
cmp eax,13 |
jne no_send |
cmp [xpos],0 |
je no_send |
mov dword [send_to_channel],ebp |
mov [send_to_server],1 |
wait_for_sending: |
mov eax,5 |
mov ebx,1 |
int 0x40 |
cmp [send_to_server],1 |
je wait_for_sending |
call draw_channel_text |
call print_entry |
jmp w_t |
no_send: |
jmp w_t |
draw_channel_text: |
pusha |
mov eax,4 |
mov ebx,10*65536+26 |
mov ecx,12 |
mov esi,[rxs] |
dct: |
pusha |
mov cx,bx |
shl ecx,16 |
mov cx,9 |
mov eax,13 |
mov ebx,10*65536 |
mov bx,word [rxs] |
imul bx,6 |
mov edx,0xffffff |
int 0x40 |
popa |
push ecx |
mov eax,4 |
mov ecx,0 |
cmp [edx],word '* ' |
jne no_red |
mov ecx,0x0000ff |
no_red: |
cmp [edx],word '**' |
jne no_light_blue |
cmp [edx+2],byte '*' |
jne no_light_blue |
mov ecx,0x0000ff |
no_light_blue: |
cmp [edx],byte '#' |
jne no_blue |
mov ecx,0x0000ff |
no_blue: |
int 0x40 |
add edx,[rxs] |
add ebx,10 |
pop ecx |
loop dct |
popa |
ret |
thread_draw_window: |
pusha |
mov eax,12 |
mov ebx,1 |
int 0x40 |
mov ebx,ebp ; draw window |
shl ebx,16+4 |
mov eax,0 |
mov ecx,ebx |
mov bx,499 |
mov cx,170 |
; mov edx,ebp ; draw window |
; imul edx,120*80 |
; add edx,I_END+120*60+8 |
; movzx edx,byte [edx] |
; imul edx,88 |
; sub bx,dx |
mov edx,[wcolor] |
add edx,0x03ffffff |
mov esi,0x80555599 |
mov edi,0x00ffffff |
int 0x40 |
mov eax,ebp ; label |
add eax,48 |
mov [labelc+14],al |
mov eax,ebp |
shl eax,5 |
add eax,channel_list |
mov esi,eax |
mov edi,labelc+17 |
movzx ecx,byte [eax+31] |
cld |
rep movsb |
mov esi,17 ; print label |
movzx ebx,byte [eax+31] |
add esi,ebx |
mov eax,4 |
mov ebx,9*65536+8 |
mov ecx,0x00ffffff |
mov edx,labelc |
int 0x40 |
mov eax,38 ; line |
mov ebx,5*65536+494 |
mov ecx,148*65536+148 |
mov edx,[channel_line_sun] |
int 0x40 |
add ecx,1*65536+1 |
mov edx,[channel_line_shadow] |
int 0x40 |
mov eax,38 ; line |
mov ebx,410*65536+410 |
mov ecx,22*65536+148 |
mov edx,[channel_line_sun] |
int 0x40 |
add ebx,1*65536+1 |
mov edx,[channel_line_shadow] |
int 0x40 |
mov eax,12 |
mov ebx,2 |
int 0x40 |
popa |
ret |
; DATA AREA |
socket dd 0x0 |
bgc dd 0x000000 |
dd 0x000000 |
dd 0x00ff00 |
dd 0x0000ff |
dd 0x005500 |
dd 0xff00ff |
dd 0x00ffff |
dd 0x770077 |
tc dd 0xffffff |
dd 0xff00ff |
dd 0xffffff |
dd 0xffffff |
dd 0xffffff |
dd 0xffffff |
dd 0xffffff |
dd 0xffffff |
channel_line_sun dd 0x9999ff |
channel_line_shadow dd 0x666699 |
cursor_on_off dd 0x0 |
max_windows dd 20 |
thread_stack dd 0x9fff0 |
thread_nro dd 1 |
thread_screen dd I_END+120*80*1 |
action_header_blue db 10,'*** ',0 |
action_header_red db 10,'*** ',0 |
action_header_short db 10,'* ',0 |
has_left_channel db ' left channel ',0 |
joins_channel db ' joined channel ',0 |
is_now_known_as db ' is now known as ',0 |
has_quit_irc db ' has quit irc',0 |
sets_mode db ' sets mode ',0 |
kicked db ' kicked from ',0 |
index_list_1 dd 0x0000bb |
index_list_2 dd 0x0000ff |
posx dd 0x0 |
incoming_pos dd 0x0 |
incoming_string: times 128 db 0 |
pos dd 0x0 |
text_start dd I_END |
irc_data dd 0x0 |
print db 0x0 |
cmd dd 0x0 |
rxs dd 66 |
res: db 0,0 |
command: times 600 db 0x0 |
nick dd 0,0,0 |
irc_command dd 0,0 |
command_position dd 0x0 |
counter dd 0 |
send_to_server db 0 |
channel_list: times 32*20 db 32 |
send_to_channel dd 0x0 |
send_string_header: db 'privmsg #eax :' |
times 100 db 0x0 |
send_string: times 100 db 0x0 |
xpos dd 0 |
string0: db 'USER guest ser1 ser2 :' |
string0l: |
string1: db 'nick ' |
string1l: |
attribute dd 0 |
scroll dd 1 |
dd 12 |
numtext db ' ' |
wcolor dd 0x000000 |
labelc db 'AIRC - WINDOW X: #xxx ' |
labelt db 'IRC client ',version |
labellen: |
;; |
;; Channel data at I_END |
;; |
;; 120*80 * channel window (1+) |
;; |
;; At Size |
;; |
;; 00 , 120*60 window text 120 characters per row |
;; 120*60 , 1 text is updated |
;; 120*60+4 , 1 close yourself |
;; 120*60+8 , 1 0 = channel window : 1 = private chat |
;; 120*61 , 256 channel name |
;; 120*61+254 , 254 channel entry text from user |
;; 120*61+255 , 1 length of entry text |
;; 120*69+248 , 4 display names from n:th name |
;; 120*69+252 , 4 length of names string |
;; 120*70 , 1200 names separated with space |
;; |
I_END: ;; |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/airc/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm airc.asm airc |
@pause |
/programs/network/airc/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm airc.asm airc |
@pause |
/programs/network/airc/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 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/arpstat/trunk/arpstat.asm |
---|
0,0 → 1,442 |
; |
; ARP Status Monitor |
; |
; Compile with FASM for Menuet |
; |
; This program displays the ARP table, and it's settings |
use32 |
org 0x0 |
db 'MENUET00' ; 8 byte id |
dd 38 ; required os |
dd START ; program start |
dd I_END ; program image size |
dd 0x100000 ; required amount of memory |
dd 0x00000000 ; reserved=no extended header |
include 'lang.inc' |
include 'macros.inc' |
START: ; start of execution |
call draw_window ; at first, draw the window |
still: |
mov eax,23 ; wait here for event |
mov ebx,200 ; Time out after 2s |
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 |
; read the stack status data, and write it to the screen buffer |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 200 |
int 0x40 |
push eax |
mov ebx, text + 24 |
call printhex |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 201 |
int 0x40 |
mov ebx, text + 64 |
call printhex |
; Fill the table with blanks |
mov edx, text + 160 |
doBlank: |
mov esi, blank |
mov edi, edx |
mov ecx, 40 |
rep movsb |
add edx, 40 |
cmp edx, text + 560 |
jne doBlank |
pop ecx ; The number of entries |
mov ebx, text+ 160 +1 ; the position for the first IP address line |
xor edx, edx ; edx is index into the ARP table |
cmp ecx, 10 |
jle show_entries |
mov ecx, 10 |
; The following code is not very efficient; Sorry about that. |
; ARPSTAT is a debugging tool, so I didn't want to put much effort in |
show_entries: |
; Ecx now holds the number of entries to populate. |
; Ebx holds the place to put the data |
; edx is a counter |
cmp ecx, 0 |
je red |
push ecx |
push edx |
push ebx |
; select the arp table entry (in edx) |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 202 |
int 0x40 |
; Read the IP address |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 203 |
int 0x40 |
; IP in eax. Get the address to put it back |
pop ebx |
push ebx |
call writeDecimal ; Extract 1 byte from eax, store it in string |
add ebx, 4 |
shr eax, 8 |
call writeDecimal ; Extract 1 byte from eax, store it in string |
add ebx, 4 |
shr eax, 8 |
call writeDecimal ; Extract 1 byte from eax, store it in string |
add ebx, 4 |
shr eax, 8 |
call writeDecimal ; Extract 1 byte from eax, store it in string |
add ebx, 4 |
; Now display the 6 byte MAC |
push ebx |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 204 |
int 0x40 |
pop ebx |
mov ecx, eax |
shr eax, 4 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
shr eax, 12 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
shr eax, 8 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
shr eax, 20 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
shr eax, 16 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
shr eax, 28 |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
shr eax, 24 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
push ebx |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 205 |
int 0x40 |
pop ebx |
mov ecx, eax |
shr eax, 4 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
shr eax, 12 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
shr eax, 8 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
; Now display the stat field |
inc ebx |
inc ebx |
push ebx |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 206 |
int 0x40 |
pop ebx |
mov ecx, eax |
shr eax, 4 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
shr eax, 12 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
shr eax, 8 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
; Now display the TTL field (this is intel word format) |
inc ebx |
inc ebx |
push ebx |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 207 |
int 0x40 |
pop ebx |
mov ecx, eax |
shr eax, 12 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
shr eax, 8 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
shr eax, 4 |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
inc ebx |
mov eax, ecx |
and eax, 0x0f |
mov al, [eax + hextable] |
mov [ebx], al |
pop ebx |
add ebx, 40 |
pop edx |
inc edx |
pop ecx |
dec ecx |
jmp show_entries |
red: ; redraw |
call draw_window |
jmp still |
key: ; Keys are not valid at this part of the |
mov eax,2 ; loop. 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,0xffffffff ; close this program |
int 0x40 |
jmp still |
writeDecimal: |
pusha |
and eax, 0xff |
mov ecx, eax |
mov dl, 100 |
div dl |
mov cl, ah |
add al, '0' |
mov [ebx], al |
inc ebx |
mov eax, ecx |
mov dl, 10 |
div dl |
mov cl, ah |
add al, '0' |
mov [ebx], al |
inc ebx |
mov al, ah |
add al, '0' |
mov [ebx], al |
popa |
ret |
; ********************************************* |
; ******* 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+280 ; [x start] *65536 + [x size] |
mov ecx,100*65536+270 ; [y start] *65536 + [y size] |
mov edx,0x03224466 ; color of work area RRGGBB |
mov esi,0x00334455 ; color of grab bar RRGGBB,8->color gl |
mov edi,0x00ddeeff ; 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,labelt ; pointer to text beginning |
mov esi,labellen-labelt ; text length |
int 0x40 |
; Re-draw the screen text |
cld |
mov ebx,25*65536+35 ; draw info text with function 4 |
mov ecx,0xffffff |
mov edx,text |
mov esi,40 |
newline: |
mov eax,4 |
int 0x40 |
add ebx,16 |
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 |
; Taken from PS.ASM |
printhex: |
; number in eax |
; print to ebx |
; xlat from hextable |
pusha |
mov esi, ebx |
add esi, 8 |
mov ebx, hextable |
mov ecx, 8 |
phex_loop: |
mov edx, eax |
and eax, 15 |
xlatb |
mov [esi], al |
mov eax, edx |
shr eax, 4 |
dec esi |
loop phex_loop |
popa |
ret |
; DATA AREA |
text: |
db ' Number of ARP entries: xxxxxxxx ' |
db ' Maximum # of entries : xxxxxxxx ' |
db ' ' |
db ' IP Address MAC Stat TTL ' |
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' |
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' |
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' |
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' |
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' |
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' |
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' |
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' |
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' |
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' |
db 'x <- END MARKER, DONT DELETE ' |
blank: |
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' |
labelt: |
db 'ARP Table ( First 10 Entries )' |
labellen: |
hextable db '0123456789ABCDEF' |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/arpstat/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm arpstat.asm arpstat |
@pause |
/programs/network/arpstat/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm arpstat.asm arpstat |
@pause |
/programs/network/arpstat/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 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/autodhcp/trunk/MACROS.INC |
---|
0,0 → 1,268 |
; 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 |
} |
; language for programs |
lang fix ru ; ru en fr ge fi |
; 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/network/autodhcp/trunk/autodhcp.asm |
---|
0,0 → 1,501 |
; |
; Automated dhcp client |
; |
; v 1.1 |
; |
; by the hidden player |
; |
DEBUG equ 1 |
TIMEOUT equ 60 ; in seconds |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; start of code |
dd IM_END ; size of image |
dd I_END ; memory for app |
dd I_END ; esp |
dd 0x0 , 0x0 ; I_Param , I_Icon |
include 'macros.inc' |
if DEBUG = 1 |
include 'debug.inc' |
end if |
START: ; start of execution |
mov eax,40 ; Report events |
mov ebx,10000000b ; Only Stack |
int 0x40 |
mov eax,52 ; first, enable the stack |
mov ebx,2 |
mov ecx,0x00000383 |
int 0x40 |
if DEBUG = 1 |
newline |
dps "DHCP: Stack Initialized" |
newline |
end if |
mov eax, 53 ; then, read in the status |
mov ebx, 255 |
mov ecx, 6 |
int 0x40 |
cmp eax,0 ; if eax is zero, no driver was found |
jne @f |
if DEBUG = 1 |
dps "DHCP: No Card detected" |
newline |
end if |
jmp close |
@@: |
if DEBUG = 1 |
dps "DHCP: Detected card: " |
dph eax |
newline |
end if |
; now that the stack is running, lets start the dhcp request |
; First, open socket |
mov eax, 53 |
mov ebx, 0 |
mov ecx, 68 ; local port dhcp client |
mov edx, 67 ; remote port - dhcp server |
mov esi, -1 ; broadcast |
int 0x40 |
mov [socketNum], eax |
if DEBUG = 1 |
dps "DHCP: Socket opened: " |
dpd eax |
newline |
end if |
; Setup the first msg we will send |
mov byte [dhcpMsgType], 0x01 ; DHCP discover |
mov dword [dhcpLease], esi ; esi is still -1 (-1 = forever) |
;*************************************************************************** |
; Function |
; buildRequest |
; |
; Description |
; Creates a DHCP request packet. |
; |
;*************************************************************************** |
buildRequest: |
; Clear dhcpMsg to all zeros |
xor eax,eax |
mov edi,dhcpMsg |
mov ecx,512 |
cld |
rep stosb |
mov edx, dhcpMsg |
mov [edx], byte 0x01 ; Boot request |
mov [edx+1], byte 0x01 ; Ethernet |
mov [edx+2], byte 0x06 ; Ethernet h/w len |
mov [edx+4], dword 0x11223344 ; xid |
mov [edx+10], byte 0x80 ; broadcast flag set |
mov [edx+236], dword 0x63538263 ; magic number |
; option DHCP msg type |
mov [edx+240], word 0x0135 |
mov al, [dhcpMsgType] |
mov [edx+240+2], al |
; option Lease time = infinity |
mov [edx+240+3], word 0x0433 |
mov eax, [dhcpLease] |
mov [edx+240+5], eax |
; ; option requested IP address |
mov [edx+240+9], word 0x0432 |
; mov eax, [dhcpClientIP] |
; mov [edx+240+11], eax |
; option request list |
mov [edx+240+15], word 0x0437 |
mov [edx+240+17], dword 0x0f060301 |
; Check which msg we are sending |
cmp [dhcpMsgType], byte 0x01 |
jne br001 |
; "Discover" options |
; end of options marker |
mov [edx+240+21], byte 0xff |
mov [dhcpMsgLen], dword 262 |
jmp ctr000 |
br001: |
; "Request" options |
; server IP |
mov [edx+240+21], word 0x0436 |
mov eax, [dhcpServerIP] |
mov [edx+240+23], eax |
; end of options marker |
mov [edx+240+27], byte 0xff |
mov [dhcpMsgLen], dword 268 |
ctr000: |
; write to socket ( send broadcast request ) |
mov eax, 53 |
mov ebx, 4 |
mov ecx, [socketNum] |
mov edx, [dhcpMsgLen] |
mov esi, dhcpMsg |
int 0x40 |
; Setup the DHCP buffer to receive response |
mov eax, dhcpMsg |
mov [dhcpMsgLen], eax ; Used as a pointer to the data |
; now, we wait for data from remote |
wait_for_data: |
mov eax,23 ; wait here for event NOTE a TIME-OUT should be placed here |
mov ebx,TIMEOUT*100 |
int 0x40 |
; Any data in the UDP receive buffer? |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
int 0x40 |
cmp eax, 0 |
jne ctr002 |
if DEBUG = 1 |
dps "DHCP: Timeout!" |
newline |
end if |
jmp close |
; we have data - this will be the response |
ctr002: |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte - block (high byte) |
; Store the data in the response buffer |
mov eax, [dhcpMsgLen] |
mov [eax], bl |
inc dword [dhcpMsgLen] |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
int 0x40 ; any more data? |
cmp eax, 0 |
jne ctr002 ; yes, so get it |
; depending on which msg we sent, handle the response |
; accordingly. |
; If the response is to a dhcp discover, then: |
; 1) If response is DHCP OFFER then |
; 1.1) record server IP, lease time & IP address. |
; 1.2) send a request packet |
; 2) else exit ( display error ) |
; If the response is to a dhcp request, then: |
; 1) If the response is DHCP ACK then |
; 1.1) extract the DNS & subnet fields. Set them in the stack |
; 2) else exit ( display error ) |
cmp [dhcpMsgType], byte 0x01 ; did we send a discover? |
je discover |
cmp [dhcpMsgType], byte 0x03 ; did we send a request? |
je request |
; should never get here - we only send discover or request |
jmp close |
discover: |
call parseResponse |
; Was the response an offer? It should be |
cmp [dhcpMsgType], byte 0x02 |
jne close ; NO - so quit |
; send request |
mov [dhcpMsgType], byte 0x03 ; DHCP request |
jmp buildRequest |
request: |
call parseResponse |
; Was the response an ACK? It should be |
cmp [dhcpMsgType], byte 0x05 |
jne close ; NO - so quit |
close: |
; close socket |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
int 0x40 |
if DEBUG = 1 |
dps "DHCP: Exiting" |
newline |
end if |
mov eax,-1 ; at last, exit |
int 0x40 |
;*************************************************************************** |
; Function |
; parseResponse |
; |
; Description |
; extracts the fields ( client IP address and options ) from |
; a DHCP response |
; The values go into |
; dhcpMsgType,dhcpLease,dhcpClientIP,dhcpServerIP, |
; dhcpDNSIP, dhcpSubnet |
; The message is stored in dhcpMsg |
; |
;*************************************************************************** |
parseResponse: |
if DEBUG = 1 |
dps "DHCP: Data received, parsing response" |
newline |
end if |
mov edx, dhcpMsg |
pusha |
mov eax,52 ; Set Client IP |
mov ebx,3 |
mov ecx, [edx+16] |
int 0x40 |
if DEBUG = 1 |
dps "DHCP: Client: " |
xor esi,esi |
.loop: |
pusha |
movzx eax,byte[edx+esi+16] |
call debug_outdec |
popa |
inc esi |
cmp esi,4 |
jne .loop |
newline |
end if |
popa |
; Scan options |
add edx, 240 ; Point to first option |
pr001: |
; Get option id |
mov al, [edx] |
cmp al, 0xff ; End of options? |
je pr_exit |
cmp al, 53 ; Msg type is a single byte option |
jne pr002 |
mov al, [edx+2] |
mov [dhcpMsgType], al |
add edx, 3 |
jmp pr001 ; Get next option |
pr002: |
; All other (accepted) options are 4 bytes in length |
inc edx |
movzx ecx, byte [edx] |
inc edx ; point to data |
cmp al, 54 ; server id |
jne pr0021 |
mov eax, [edx] ; All options are 4 bytes, so get it |
mov [dhcpServerIP], eax |
jmp pr003 |
pr0021: |
cmp al, 51 ; lease |
jne pr0022 |
if DEBUG = 1 |
pusha |
dps "DHCP: lease: " |
cmp dword[edx],-1 |
jne no_lease_forever |
dps "forever" |
jmp lease_newline |
no_lease_forever: |
dpd [edx] |
lease_newline: |
newline |
popa |
end if |
jmp pr003 |
pr0022: |
cmp al, 1 ; subnet mask |
jne pr0023 |
pusha |
mov eax,52 |
mov ebx,12 |
mov ecx,[edx] |
int 0x40 |
if DEBUG = 1 |
dps "DHCP: Subnet: " |
xor esi,esi |
.loop: |
pusha |
movzx eax,byte[edx+esi] |
call debug_outdec |
popa |
inc esi |
cmp esi,4 |
jne .loop |
newline |
end if |
popa |
jmp pr003 |
pr0023: |
cmp al, 6 ; dns ip |
jne pr0024 |
pusha |
mov eax,52 |
mov ebx,14 |
mov ecx,[edx] |
int 0x40 |
if DEBUG = 1 |
dps "DHCP: DNS IP: " |
xor esi,esi |
.loop: |
pusha |
movzx eax,byte[edx+esi] |
call debug_outdec |
popa |
inc esi |
cmp esi,4 |
jne .loop |
newline |
end if |
popa |
pr0024: |
cmp al, 3 ; gateway ip |
jne pr003 |
pusha |
mov eax,52 |
mov ebx,11 |
mov ecx,[edx] |
int 0x40 |
if DEBUG = 1 |
dps "DHCP: Gateway:" |
xor esi,esi |
.loop: |
pusha |
movzx eax,byte[edx+esi] |
call debug_outdec |
popa |
inc esi |
cmp esi,4 |
jne .loop |
newline |
end if |
popa |
pr003: |
add edx, ecx |
jmp pr001 |
pr_exit: |
if DEBUG = 1 |
dps "DHCP: Done" |
newline |
end if |
jmp close |
; DATA AREA |
IM_END: |
dhcpMsgType: db 0 |
dhcpLease: dd 0 |
;dhcpClientIP: dd 0 |
dhcpServerIP: dd 0 |
dhcpMsgLen: dd 0 |
socketNum: dd 0xFFFF |
dhcpMsg: rb 512 |
I_END: |
/programs/network/autodhcp/trunk/debug.inc |
---|
0,0 → 1,131 |
macro debug_print str |
{ |
local ..string, ..label |
jmp ..label |
..string db str,0 |
..label: |
pushf |
pushad |
mov edx,..string |
call debug_outstr |
popad |
popf |
} |
dps fix debug_print |
macro debug_print_dec arg |
{ |
pushf |
pushad |
if ~arg eq eax |
mov eax,arg |
end if |
call debug_outdec |
popad |
popf |
} |
dpd fix debug_print_dec |
;--------------------------------- |
debug_outdec: ;(eax - num, edi-str) |
push 10 ;2 |
pop ecx ;1 |
push -'0' ;2 |
.l0: |
xor edx,edx ;2 |
div ecx ;2 |
push edx ;1 |
test eax,eax ;2 |
jnz .l0 ;2 |
.l1: |
pop eax ;1 |
add al,'0' ;2 |
call debug_outchar ; stosb |
jnz .l1 ;2 |
ret ;1 |
;--------------------------------- |
debug_outchar: ; al - char |
pushf |
pushad |
mov cl,al |
mov eax,63 |
mov ebx,1 |
int 0x40 |
popad |
popf |
ret |
debug_outstr: |
mov eax,63 |
mov ebx,1 |
@@: |
mov cl,[edx] |
test cl,cl |
jz @f |
int 40h |
inc edx |
jmp @b |
@@: |
ret |
macro newline |
{ |
dps <13,10> |
} |
macro print message |
{ |
dps message |
newline |
} |
macro pregs |
{ |
dps "EAX: " |
dpd eax |
dps " EBX: " |
dpd ebx |
newline |
dps "ECX: " |
dpd ecx |
dps " EDX: " |
dpd edx |
newline |
} |
macro debug_print_hex arg |
{ |
pushf |
pushad |
if ~arg eq eax |
mov eax, arg |
end if |
call debug_outhex |
popad |
popf |
} |
dph fix debug_print_hex |
debug_outhex: |
; eax - number |
mov edx, 8 |
.new_char: |
rol eax, 4 |
movzx ecx, al |
and cl, 0x0f |
mov cl, [__hexdigits + ecx] |
pushad |
mcall 63, 1 |
popad |
dec edx |
jnz .new_char |
ret |
__hexdigits: |
db '0123456789ABCDEF' |
/programs/network/dhcp/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm dhcp.asm dhcp |
@pause |
/programs/network/dhcp/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm dhcp.asm dhcp |
@pause |
/programs/network/dhcp/trunk/dhcp.asm |
---|
0,0 → 1,595 |
; |
; DHCP Client |
; |
; Compile with FASM for Menuet |
; |
include 'lang.inc' |
include 'macros.inc' |
use32 |
org 0x0 |
db 'MENUET00' ; 8 byte id |
dd 38 ; required os |
dd START ; program start |
dd I_END ; program image size |
dd 0x100000 ; required amount of memory |
dd 0x00000000 ; reserved=no extended header |
START: ; start of execution |
mov eax,40 ; Report events |
mov ebx,10000111b ; Stack 8 + defaults |
int 0x40 |
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: ; Keys are not valid at this part of the |
mov eax,2 ; loop. 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 noclose |
; close socket before exiting |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
int 0x40 |
mov eax,0xffffffff ; close this program |
int 0x40 |
noclose: |
cmp ah,3 ; Resolve address? |
jnz still |
call draw_window |
call contactDHCPServer |
jmp still |
;*************************************************************************** |
; Function |
; parseResponse |
; |
; Description |
; extracts the fields ( client IP address and options ) from |
; a DHCP response |
; The values go into |
; dhcpMsgType,dhcpLease,dhcpClientIP,dhcpServerIP, |
; dhcpDNSIP, dhcpSubnet |
; The message is stored in dhcpMsg |
; |
;*************************************************************************** |
parseResponse: |
mov edx, dhcpMsg |
mov eax, [edx+16] |
mov [dhcpClientIP], eax |
; Scan options |
add edx, 240 ; Point to first option |
pr001: |
; Get option id |
mov al, [edx] |
cmp al, 0xff ; End of options? |
je pr_exit |
cmp al, 53 ; Msg type is a single byte option |
jne pr002 |
mov al, [edx+2] |
mov [dhcpMsgType], al |
add edx, 3 |
jmp pr001 ; Get next option |
pr002: |
; All other (accepted) options are 4 bytes in length |
inc edx |
movzx ecx, byte [edx] |
inc edx ; point to data |
cmp al, 54 ; server id |
jne pr0021 |
mov eax, [edx] ; All options are 4 bytes, so get it |
mov [dhcpServerIP], eax |
jmp pr003 |
pr0021: |
cmp al, 51 ; lease |
jne pr0022 |
mov eax, [edx] ; All options are 4 bytes, so get it |
mov [dhcpLease], eax |
jmp pr003 |
pr0022: |
cmp al, 1 ; subnet mask |
jne pr0023 |
mov eax, [edx] ; All options are 4 bytes, so get it |
mov [dhcpSubnet], eax |
jmp pr003 |
pr0023: |
cmp al, 6 ; dns ip |
jne pr0024 |
mov eax, [edx] ; All options are 4 bytes, so get it |
mov [dhcpDNSIP], eax |
pr0024: |
cmp al, 3 ; gateway ip |
jne pr003 |
mov eax, [edx] ; All options are 4 bytes, so get it |
mov [dhcpGateway], eax |
pr003: |
add edx, ecx |
jmp pr001 |
pr_exit: |
ret |
;*************************************************************************** |
; Function |
; buildRequest |
; |
; Description |
; Creates a DHCP request packet. |
; |
;*************************************************************************** |
buildRequest: |
; Clear dhcpMsg to all zeros |
xor eax,eax |
mov edi,dhcpMsg |
mov ecx,512 |
cld |
rep stosb |
mov edx, dhcpMsg |
mov [edx], byte 0x01 ; Boot request |
mov [edx+1], byte 0x01 ; Ethernet |
mov [edx+2], byte 0x06 ; Ethernet h/w len |
mov [edx+4], dword 0x11223344 ; xid |
mov [edx+10], byte 0x80 ; broadcast flag set |
mov [edx+236], dword 0x63538263 ; magic number |
; option DHCP msg type |
mov [edx+240], word 0x0135 |
mov al, [dhcpMsgType] |
mov [edx+240+2], al |
; option Lease time = infinity |
mov [edx+240+3], word 0x0433 |
mov eax, [dhcpLease] |
mov [edx+240+5], eax |
; option requested IP address |
mov [edx+240+9], word 0x0432 |
mov eax, [dhcpClientIP] |
mov [edx+240+11], eax |
; option request list |
mov [edx+240+15], word 0x0437 |
mov [edx+240+17], dword 0x0f060301 |
; Check which msg we are sending |
cmp [dhcpMsgType], byte 0x01 |
jne br001 |
; "Discover" options |
; end of options marker |
mov [edx+240+21], byte 0xff |
mov [dhcpMsgLen], dword 262 |
jmp br_exit |
br001: |
; "Request" options |
; server IP |
mov [edx+240+21], word 0x0436 |
mov eax, [dhcpServerIP] |
mov [edx+240+23], eax |
; end of options marker |
mov [edx+240+27], byte 0xff |
mov [dhcpMsgLen], dword 268 |
br_exit: |
ret |
;*************************************************************************** |
; Function |
; contactDHCPServer |
; |
; Description |
; negotiates settings with a DHCP server |
; |
;*************************************************************************** |
contactDHCPServer: |
; First, open socket |
mov eax, 53 |
mov ebx, 0 |
mov ecx, 68 ; local port dhcp client |
mov edx, 67 ; remote port - dhcp server |
mov esi, 0xffffffff ; broadcast |
int 0x40 |
mov [socketNum], eax |
; Setup the first msg we will send |
mov [dhcpMsgType], byte 0x01 ; DHCP discover |
mov [dhcpLease], dword 0xffffffff |
mov [dhcpClientIP], dword 0 |
mov [dhcpServerIP], dword 0 |
call buildRequest |
ctr000: |
; write to socket ( send broadcast request ) |
mov eax, 53 |
mov ebx, 4 |
mov ecx, [socketNum] |
mov edx, [dhcpMsgLen] |
mov esi, dhcpMsg |
int 0x40 |
; Setup the DHCP buffer to receive response |
mov eax, dhcpMsg |
mov [dhcpMsgLen], eax ; Used as a pointer to the data |
; now, we wait for |
; UI redraw |
; UI close |
; or data from remote |
ctr001: |
mov eax,10 ; wait here for event |
int 0x40 |
cmp eax,1 ; redraw request ? |
je ctr003 |
cmp eax,2 ; key in buffer ? |
je ctr004 |
cmp eax,3 ; button in buffer ? |
je ctr005 |
; Any data in the UDP receive buffer? |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
int 0x40 |
cmp eax, 0 |
je ctr001 |
; we have data - this will be the response |
ctr002: |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte - block (high byte) |
; Store the data in the response buffer |
mov eax, [dhcpMsgLen] |
mov [eax], bl |
inc dword [dhcpMsgLen] |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
int 0x40 ; any more data? |
cmp eax, 0 |
jne ctr002 ; yes, so get it |
; depending on which msg we sent, handle the response |
; accordingly. |
; If the response is to a dhcp discover, then: |
; 1) If response is DHCP OFFER then |
; 1.1) record server IP, lease time & IP address. |
; 1.2) send a request packet |
; 2) else exit ( display error ) |
; If the response is to a dhcp request, then: |
; 1) If the response is DHCP ACK then |
; 1.1) extract the DNS & subnet fields. Set them in the stack |
; 2) else exit ( display error ) |
cmp [dhcpMsgType], byte 0x01 ; did we send a discover? |
je ctr007 |
cmp [dhcpMsgType], byte 0x03 ; did we send a request? |
je ctr008 |
; should never get here - we only send discover or request |
jmp ctr006 |
ctr007: |
call parseResponse |
; Was the response an offer? It should be |
cmp [dhcpMsgType], byte 0x02 |
jne ctr006 ; NO - so quit |
; send request |
mov [dhcpMsgType], byte 0x03 ; DHCP request |
call buildRequest |
jmp ctr000 |
ctr008: |
call parseResponse |
; Was the response an ACK? It should be |
cmp [dhcpMsgType], byte 0x05 |
jne ctr006 ; NO - so quit |
; Set or display addresses here... |
ctr006: |
; close socket |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
int 0x40 |
mov [socketNum], dword 0xFFFF |
call draw_window |
jmp ctr001 |
ctr003: ; redraw |
call draw_window |
jmp ctr001 |
ctr004: ; key |
mov eax,2 ; just read it and ignore |
int 0x40 |
jmp ctr001 |
ctr005: ; button |
mov eax,17 ; get id |
int 0x40 |
; close socket |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
int 0x40 |
mov [socketNum], dword 0xFFFF |
call draw_window ; at first, draw the window |
ret |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
; Pass in the IP address in edi |
; row to display in [ya] |
drawIP: |
; mov edi,hostIP |
mov ecx, edi |
add ecx, 4 |
mov edx,[ya] |
add edx, 97*65536 |
mov esi,0x00ffffff |
mov ebx,3*65536 |
ipdisplay: |
mov eax,47 |
push ecx |
movzx ecx,byte [edi] |
int 0x40 |
pop ecx |
add edx,6*4*65536 |
inc edi |
cmp edi,ecx |
jb ipdisplay |
ret |
drawDHMS: |
mov eax,[edi] |
bswap eax |
mov esi,dhms |
mov ecx,16 |
mov edi,text+40*4+12 |
cmp eax,0xffffffff |
jne nforever |
mov esi,forever |
cld |
rep movsb |
ret |
nforever: |
cld |
rep movsb |
mov ecx,28 |
xor edx,edx |
mov ebx,60 |
div ebx |
call displayDHMS |
xor edx,edx |
div ebx |
call displayDHMS |
xor edx,edx |
mov ebx,24 |
div ebx |
call displayDHMS |
mov edx,eax |
call displayDHMS |
ret |
displayDHMS: |
pusha |
mov eax,47 |
mov ebx,3*65536 |
mov edx,ecx |
imul edx,6 |
shl edx,16 |
add edx,1*65536+99 |
mov ecx,[esp+20] |
mov esi,0xffffff |
int 0x40 |
popa |
sub ecx,4 |
ret |
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+156 ; [y start] *65536 + [y size] |
mov edx,0x03224466 ; color of work area RRGGBB |
mov esi,0x00334455 ; color of grab bar RRGGBB,8->color gl |
mov edi,0x00ddeeff ; 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,labelt ; pointer to text beginning |
mov esi,labellen-labelt ; text length |
int 0x40 |
mov eax,8 ; Resolve |
mov ebx,20*65536+90 |
mov ecx,127*65536+15 |
mov edx,3 |
mov esi,0x557799 |
int 0x40 |
; Pass in the IP address in edi |
; row to display in [ya] |
mov edi, dhcpClientIP |
mov eax, 35 |
mov [ya], eax |
call drawIP |
mov edi, dhcpGateway |
mov eax, 35 + 16 |
mov [ya], eax |
call drawIP |
mov edi, dhcpSubnet |
mov eax, 35 + 32 |
mov [ya], eax |
call drawIP |
mov edi, dhcpDNSIP |
mov eax, 35 + 48 |
mov [ya], eax |
call drawIP |
mov edi, dhcpLease |
call drawDHMS |
; Re-draw the screen text |
cld |
mov ebx,25*65536+35 ; draw info text with function 4 |
mov ecx,0xffffff |
mov edx,text |
mov esi,40 |
newline: |
mov eax,4 |
int 0x40 |
add ebx,16 |
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 |
ya dd 0x0 |
text: |
db 'Client IP : . . . ' |
db 'Gateway IP: . . . ' |
db 'Subnet : . . . ' |
db 'DNS IP : . . . ' |
db 'Lease Time: d h m s ' |
db ' ' |
db ' SEND REQUEST ' |
db 'x <- END MARKER, DONT DELETE ' |
dhms db ' d h m s' |
forever db 'Forever ' |
labelt: db 'DHCP Client Test' |
labellen: |
dhcpMsgType: db 0 |
dhcpLease: dd 0 |
dhcpClientIP: dd 0 |
dhcpServerIP: dd 0 |
dhcpDNSIP: dd 0 |
dhcpSubnet: dd 0 |
dhcpGateway: dd 0 |
dhcpMsgLen: dd 0 |
socketNum: dd 0xFFFF |
dhcpMsg: |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/dhcp/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 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/dnsr/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm dnsr.asm dnsr |
@pause |
/programs/network/dnsr/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm dnsr.asm dnsr |
@pause |
/programs/network/dnsr/trunk/dnsr.asm |
---|
0,0 → 1,780 |
; |
; DNS Domain name -> IP lookup |
; |
; Compile with FASM for Menuet |
; |
; If you like, you camd change the DNS server default by changing the |
; IP address in the dnsServer string. |
; Enabling debugging puts the received response to the |
; debug board |
DEBUGGING_ENABLED equ 1 |
DEBUGGING_DISABLED equ 0 |
DEBUGGING_STATE equ DEBUGGING_DISABLED |
use32 |
org 0x0 |
db 'MENUET00' ; 8 byte id |
dd 38 ; required os |
dd START ; program start |
dd I_END ; program image size |
dd 0x100000 ; required amount of memory |
dd 0x00000000 ; reserved=no extended header |
include 'lang.inc' |
include 'macros.inc' |
START: ; start of execution |
mov eax,40 ; Report events |
mov ebx,10000111b ; Stack 8 + defaults |
int 0x40 |
mov dword [prompt], p1 |
mov dword [promptlen], p1len - p1 ; 'waiting for command' |
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: ; Keys are not valid at this part of the |
mov eax,2 ; loop. 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 noclose |
; close socket before exiting |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
int 0x40 |
mov eax,0xffffffff ; close this program |
int 0x40 |
noclose: |
cmp ah,3 ; Resolve address? |
jnz noresolve |
mov dword [prompt], p5 |
mov dword [promptlen], p5len - p5 ; display 'Resolving' |
call draw_window |
call translateData ; Convert domain & DNS IP address |
call resolveDomain |
jmp still |
noresolve: |
cmp ah,4 |
jz f1 ; Enter domain name |
cmp ah,5 |
jz f2 ; enter DNS Server IP |
jmp still |
f1: |
mov [addr],dword query |
mov [ya],dword 35 |
jmp rk |
f2: |
mov [addr],dword dnsServer |
mov [ya],dword 35+16 |
rk: |
mov ecx,26 |
mov edi,[addr] |
mov al,' ' |
rep stosb |
call print_text |
mov edi,[addr] |
f11: |
mov eax,10 |
int 0x40 |
cmp eax,2 |
jz fbu |
jmp still |
fbu: |
mov eax,2 |
int 0x40 ; get key |
shr eax,8 |
cmp eax,8 |
jnz nobs |
cmp edi,[addr] |
jz f11 |
sub edi,1 |
mov [edi],byte ' ' |
call print_text |
jmp f11 |
nobs: |
cmp eax,dword 31 |
jbe f11 |
cmp eax,dword 95 |
jb keyok |
sub eax,32 |
keyok: |
mov [edi],al |
call print_text |
add edi,1 |
mov esi,[addr] |
add esi,26 |
cmp esi,edi |
jnz f11 |
jmp still |
print_text: |
mov eax,13 |
mov ebx,103*65536+26*6 |
mov ecx,[ya] |
shl ecx,16 |
mov cx,8 |
mov edx,0x224466 |
int 0x40 |
mov eax,4 |
mov ebx,103*65536 |
add ebx,[ya] |
mov ecx,0xffffff |
mov edx,[addr] |
mov esi,26 |
int 0x40 |
ret |
;*************************************************************************** |
; Function |
; translateData |
; |
; Description |
; Coverts the domain name and DNS IP address typed in by the user into |
; a format suitable for the IP layer. |
; |
; The ename, in query, is converted and stored in dnsMsg |
; The DNS ip, in dnsServer, is converted and stored in dnsIP |
; |
;*************************************************************************** |
translateData: |
; first, get the IP address of the DNS server |
; Then, build up the request string. |
xor eax, eax |
mov dh, 10 |
mov dl, al |
mov [dnsIP], eax |
mov esi, dnsServer |
mov edi, dnsIP |
mov ecx, 4 |
td003: |
lodsb |
sub al, '0' |
add dl, al |
lodsb |
cmp al, '.' |
je ipNext |
cmp al, ' ' |
je ipNext |
mov dh, al |
sub dh, '0' |
mov al, 10 |
mul dl |
add al, dh |
mov dl, al |
lodsb |
cmp al, '.' |
je ipNext |
cmp al, ' ' |
je ipNext |
mov dh, al |
sub dh, '0' |
mov al, 10 |
mul dl |
add al, dh |
mov dl, al |
lodsb |
ipNext: |
mov [edi], dl |
inc edi |
mov dl, 0 |
loop td003 |
; Build the request string |
mov eax, 0x00010100 |
mov [dnsMsg], eax |
mov eax, 0x00000100 |
mov [dnsMsg+4], eax |
mov eax, 0x00000000 |
mov [dnsMsg+8], eax |
; domain name goes in at dnsMsg+12 |
mov esi, dnsMsg + 12 ; location of label length |
mov edi, dnsMsg + 13 ; label start |
mov edx, query |
mov ecx, 12 ; total string length so far |
td002: |
mov [esi], byte 0 |
inc ecx |
td0021: |
mov al, [edx] |
cmp al, ' ' |
je td001 ; we have finished the string translation |
cmp al, '.' ; we have finished the label |
je td004 |
inc byte [esi] |
inc ecx |
mov [edi], al |
inc edi |
inc edx |
jmp td0021 |
td004: |
mov esi, edi |
inc edi |
inc edx |
jmp td002 |
; write label len + label text |
td001: |
mov [edi], byte 0 |
inc ecx |
inc edi |
mov [edi], dword 0x01000100 |
add ecx, 4 |
mov [dnsMsgLen], ecx |
ret |
;*************************************************************************** |
; Function |
; resolveDomain |
; |
; Description |
; Sends a question to the dns server |
; works out the IP address from the response from the DNS server |
; |
;*************************************************************************** |
resolveDomain: |
; Get a free port number |
mov ecx, 1000 ; local port starting at 1000 |
getlp: |
inc ecx |
push ecx |
mov eax, 53 |
mov ebx, 9 |
int 0x40 |
pop ecx |
cmp eax, 0 ; is this local port in use? |
jz getlp ; yes - so try next |
; First, open socket |
mov eax, 53 |
mov ebx, 0 |
mov edx, 53 ; remote port - dns |
mov esi, [dnsIP] |
int 0x40 |
mov [socketNum], eax |
; write to socket ( request DNS lookup ) |
mov eax, 53 |
mov ebx, 4 |
mov ecx, [socketNum] |
mov edx, [dnsMsgLen] |
mov esi, dnsMsg |
int 0x40 |
; Setup the DNS response buffer |
mov eax, dnsMsg |
mov [dnsMsgLen], eax |
; now, we wait for |
; UI redraw |
; UI close |
; or data from remote |
ctr001: |
mov eax,10 ; wait here for event |
int 0x40 |
cmp eax,1 ; redraw request ? |
je ctr003 |
cmp eax,2 ; key in buffer ? |
je ctr004 |
cmp eax,3 ; button in buffer ? |
je ctr005 |
; Any data in the UDP receive buffer? |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
int 0x40 |
cmp eax, 0 |
je ctr001 |
; we have data - this will be the response |
ctr002: |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte - block (high byte) |
; Store the data in the response buffer |
mov eax, [dnsMsgLen] |
mov [eax], bl |
inc dword [dnsMsgLen] |
if DEBUGGING_STATE = DEBUGGING_ENABLED |
call debug_print_rx_ip |
end if |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
int 0x40 ; any more data? |
cmp eax, 0 |
jne ctr002 ; yes, so get it |
; close socket |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
int 0x40 |
mov [socketNum], dword 0xFFFF |
; Now parse the message to get the host IP |
; Man, this is complicated. It's described in |
; RFC 1035 |
; 1) Validate that we have an answer with > 0 responses |
; 2) Find the answer record with TYPE 0001 ( host IP ) |
; 3) Finally, copy the IP address to the display |
; Note: The response is in dnsMsg |
; The end of the buffer is pointed to by [dnsMsgLen] |
; Clear the IP address text |
mov [hostIP], dword 0 |
mov esi, dnsMsg |
; Is this a response to my question? |
mov al, [esi+2] |
and al, 0x80 |
cmp al, 0x80 |
jne ctr002a |
; Were there any errors? |
mov al, [esi+3] |
and al, 0x0F |
cmp al, 0x00 |
jne ctr002a |
; Is there ( at least 1 ) answer? |
mov ax, [esi+6] |
cmp ax, 0x00 |
je ctr002a |
; Header validated. Scan through and get my answer |
add esi, 12 ; Skip to the question field |
; Skip through the question field |
call skipName |
add esi, 4 ; skip past the questions qtype, qclass |
ctr002z: |
; Now at the answer. There may be several answers, |
; find the right one ( TYPE = 0x0001 ) |
call skipName |
mov ax, [esi] |
cmp ax, 0x0100 ; Is this the IP address answer? |
jne ctr002c |
; Yes! Point esi to the first byte of the IP address |
add esi, 10 |
mov eax, [esi] |
mov [hostIP], eax |
jmp ctr002a ; And exit... |
ctr002c: ; Skip through the answer, move to the next |
add esi, 8 |
movzx eax, byte [esi+1] |
mov ah, [esi] |
add esi, eax |
add esi, 2 |
; Have we reached the end of the msg? |
; This is an error condition, should not happen |
cmp esi, [dnsMsgLen] |
jl ctr002z ; Check next answer |
jmp ctr002a ; abort |
ctr002a: |
mov dword [prompt], p4 ; Display IP address |
mov dword [promptlen], p4len - p4 |
call draw_window |
jmp ctr001 |
ctr003: ; redraw |
call draw_window |
jmp ctr001 |
ctr004: ; key |
mov eax,2 ; just read it and ignore |
int 0x40 |
jmp ctr001 |
ctr005: ; button |
mov eax,17 ; get id |
int 0x40 |
; close socket |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
int 0x40 |
mov [socketNum], dword 0xFFFF |
mov [hostIP], dword 0 |
mov dword [prompt], p1 |
mov dword [promptlen], p1len - p1 ; 'waiting for command' |
call draw_window ; at first, draw the window |
ret |
;*************************************************************************** |
; Function |
; skipName |
; |
; Description |
; Increment esi to the first byte past the name field |
; Names may use compressed labels. Normally do. |
; RFC 1035 page 30 gives details |
; |
;*************************************************************************** |
skipName: |
mov al, [esi] |
cmp al, 0 |
je sn_exit |
and al, 0xc0 |
cmp al, 0xc0 |
je sn001 |
movzx eax, byte [esi] |
inc eax |
add esi, eax |
jmp skipName |
sn001: |
add esi, 2 ; A pointer is always at the end |
ret |
sn_exit: |
inc esi |
ret |
; ********************************************* |
; ******* 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+140 ; [y start] *65536 + [y size] |
mov edx,0x03224466 ; color of work area RRGGBB |
mov esi,0x00334455 ; color of grab bar RRGGBB,8->color gl |
mov edi,0x00ddeeff ; 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,labelt ; pointer to text beginning |
mov esi,labellen-labelt ; text length |
int 0x40 |
mov eax,8 ; Resolve |
mov ebx,20*65536+190 |
mov ecx,79*65536+15 |
mov edx,3 |
mov esi,0x557799 |
int 0x40 |
mov eax,8 |
mov ebx,270*65536+10 |
mov ecx,34*65536+10 |
mov edx,4 |
mov esi,0x557799 |
int 0x40 |
mov eax,8 |
mov ebx,270*65536+10 |
mov ecx,50*65536+10 |
mov edx,5 |
mov esi,0x557799 |
int 0x40 |
; Copy the file name to the screen buffer |
; file name is same length as IP address, to |
; make the math easier later. |
cld |
mov esi,query |
mov edi,text+13 |
mov ecx,26 |
rep movsb |
; copy the IP address to the screen buffer |
mov esi,dnsServer |
mov edi,text+40+13 |
mov ecx,26 |
rep movsb |
; copy the prompt to the screen buffer |
mov esi,[prompt] |
mov edi,text+200 |
mov ecx,[promptlen] |
rep movsb |
; Re-draw the screen text |
cld |
mov ebx,25*65536+35 ; draw info text with function 4 |
mov ecx,0xffffff |
mov edx,text |
mov esi,40 |
newline: |
mov eax,4 |
int 0x40 |
add ebx,16 |
add edx,40 |
cmp [edx],byte 'x' |
jnz newline |
; Write the host IP, if we have one |
mov eax, [hostIP] |
cmp eax, 0 |
je dw001 |
; We have an IP address... display it |
mov edi,hostIP |
mov edx,97*65536+115 |
mov esi,0x00ffffff |
mov ebx,3*65536 |
ipdisplay: |
mov eax,47 |
movzx ecx,byte [edi] |
int 0x40 |
add edx,6*4*65536 |
inc edi |
cmp edi,hostIP+4 |
jb ipdisplay |
dw001: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
ret |
if DEBUGGING_STATE = DEBUGGING_ENABLED |
;**************************************************************************** |
; Function |
; debug_print_string |
; |
; Description |
; prints a string to the debug board |
; |
; esi holds ptr to msg to display |
; |
; Nothing preserved; I'm assuming a pusha/popa is done before calling |
; |
;**************************************************************************** |
debug_print_string: |
mov cl, [esi] |
cmp cl, 0 |
jnz dps_001 |
ret |
dps_001: |
mov eax,63 |
mov ebx, 1 |
push esi |
int 0x40 |
inc word [ind] |
mov ax, [ind] |
and ax, 0x1f |
cmp ax, 0 |
jne ds1 |
mov cl, 13 |
mov eax,63 |
mov ebx, 1 |
int 0x40 |
mov cl, 10 |
mov eax,63 |
mov ebx, 1 |
int 0x40 |
ds1: |
pop esi |
inc esi |
jmp debug_print_string |
ind: dw 0 |
; This is used for translating hex to ASCII for display or output |
hexchars db '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' |
IP_STR db 'xx',0 |
debug_print_rx_ip: |
pusha |
mov edi, IP_STR |
xor eax, eax |
mov al, bl |
shr al, 4 |
mov ah, [eax + hexchars] |
mov [edi], ah |
inc edi |
xor eax, eax |
mov al, bl |
and al, 0x0f |
mov ah, [eax + hexchars] |
mov [edi], ah |
mov esi, IP_STR |
call debug_print_string |
popa |
ret |
end if |
; DATA AREA |
addr dd 0x0 |
ya dd 0x0 |
text: |
db 'Host name : xxxxxxxxxxxxxxx ' |
db 'DNS server : xxx.xxx.xxx.xxx ' |
db ' ' |
db ' RESOLVE ADDRESS ' |
db ' ' |
db ' ' |
db 'x <- END MARKER, DONT DELETE ' |
labelt: |
db 'DNS Client' |
labellen: |
prompt: dd 0 |
promptlen: dd 0 |
p1: db 'Waiting for Command ' |
p1len: |
p4: db 'IP Address: . . . ' |
p4len: |
p5: db 'Resolving... ' |
p5len: |
dnsServer db '194.145.128.1 ' ; iolfree.ie DNS |
query db 'WWW.MENUETOS.ORG ' |
hostIP: dd 0 |
dnsIP: dd 0 |
dnsMsgLen: dd 0 |
socketNum: dd 0xFFFF |
dnsMsg: |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/dnsr/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 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/ethstat/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm ethstat.asm ethstat |
@pause |
/programs/network/ethstat/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm ethstat.asm ethstat |
@pause |
/programs/network/ethstat/trunk/ethstat.asm |
---|
0,0 → 1,228 |
; |
; Stack Status Monitor |
; |
; 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 0x100000 ; required amount of memory |
dd 0x00000000 ; reserved=no extended header |
include 'lang.inc' |
include 'macros.inc' |
START: ; start of execution |
call draw_window ; at first, draw the window |
still: |
mov eax,23 ; wait here for event |
mov ebx,200 ; Time out after 2s |
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 |
; read the stack status data, and write it to the screen buffer |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 6 |
int 0x40 |
mov ebx, text + 24 |
call printhex |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 2 |
int 0x40 |
mov ebx, text + 107 |
call printhex |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 5 |
int 0x40 |
mov ebx, text + 107 + 40 |
call printhex |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 4 |
int 0x40 |
mov ebx, text + 107 + 80 |
call printhex |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 100 |
int 0x40 |
mov ebx, text + 258 |
call printhex |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 101 |
int 0x40 |
mov ebx, text + 258 + 40 |
call printhex |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 102 |
int 0x40 |
mov ebx, text + 258 + 80 |
call printhex |
mov eax, 53 |
mov ebx, 255 |
mov ecx, 103 |
int 0x40 |
mov ebx, text + 258 + 120 |
call printhex |
red: ; redraw |
call draw_window |
jmp still |
key: ; Keys are not valid at this part of the |
mov eax,2 ; loop. 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,0xffffffff ; close this program |
int 0x40 |
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+260 ; [x start] *65536 + [x size] |
mov ecx,100*65536+205 ; [y start] *65536 + [y size] |
mov edx,0x03224466 ; color of work area RRGGBB |
mov esi,0x00334455 ; color of grab bar RRGGBB,8->color gl |
mov edi,0x00ddeeff ; 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,labelt ; pointer to text beginning |
mov esi,labellen-labelt ; text length |
int 0x40 |
; Re-draw the screen text |
cld |
mov ebx,25*65536+35 ; draw info text with function 4 |
mov ecx,0xffffff |
mov edx,text |
mov esi,40 |
newline: |
mov eax,4 |
int 0x40 |
add ebx,16 |
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 |
; Taken from PS.ASM |
printhex: |
; number in eax |
; print to ebx |
; xlat from hextable |
pusha |
mov esi, ebx |
add esi, 8 |
mov ebx, hextable |
mov ecx, 8 |
phex_loop: |
mov edx, eax |
and eax, 15 |
xlatb |
mov [esi], al |
mov eax, edx |
shr eax, 4 |
dec esi |
loop phex_loop |
popa |
ret |
; DATA AREA |
text: |
db ' Ethernet card status : xxxxxxxx ' |
db ' ' |
db ' IP packets received : xxxxxxxx ' |
db ' ARP packets received : xxxxxxxx ' |
db ' Dumped received packets : xxxxxxxx ' |
db ' ' |
db ' EMPTY QUEUE : xxxxxxxx ' |
db ' IPOUT QUEUE : xxxxxxxx ' |
db ' IPIN QUEUE : xxxxxxxx ' |
db ' NET1OUT QUEUE : xxxxxxxx ' |
db 'x <- END MARKER, DONT DELETE ' |
labelt: |
db 'Stack Status' |
labellen: |
hextable db '0123456789ABCDEF' |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/ethstat/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 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/httpc/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm httpc.asm httpc |
@pause |
/programs/network/httpc/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm httpc.asm httpc |
@pause |
/programs/network/httpc/trunk/httpc.asm |
---|
0,0 → 1,1529 |
; |
; HTTPC.ASM |
; |
; Compile with FASM for Menuet ( v1.40 for DOS ) |
; |
; This program implements a very simple web browser |
; |
; Version 0.4 2nd December 2003 Mike Hibbett |
; Enabled lowercase/uppcase characters in URL |
; Version 0.3 30th November 2003 Mike Hibbett |
; Fixed bug with tcp socket opne - uses unique port |
; Version 0.2 27th November 2003 Mike Hibbett |
; Added user entry of url, and implements url -> IP address |
; resolution through DNS |
; |
; Version 0.1 Ville Mikael Turjanmaa |
; Original version |
; Enabling debugging puts stuff to the debug board |
DEBUGGING_ENABLED equ 1 |
DEBUGGING_DISABLED equ 0 |
DEBUGGING_STATE equ DEBUGGING_DISABLED |
use32 |
org 0x0 |
db 'MENUET00' ; 8 byte id |
dd 38 ; required os |
dd START ; program start |
dd I_END ; program image size |
dd 0x100000 ; required amount of memory |
dd 0x00000000 ; reserved=no extended header |
include 'lang.inc' |
include 'macros.inc' |
;include "DEBUG.INC" |
URLMAXLEN equ 50 ; maximum length of url string |
; Memory usage |
; webpage source file at 0x10000 |
; decoded text page at 0x20000 |
; text attribute 0x30000 (1 = normal, 2 = bold, 128+ = link) |
START: ; start of execution |
;dps <"Program started",13,10> |
mov eax,40 ; Report events |
mov ebx,10000111b ; Stack 8 + defaults |
int 0x40 |
call draw_window |
still: |
mov eax,23 ; wait here for event |
mov ebx,1 |
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 |
; Get the web page data from the remote server |
call read_incoming_data |
mov eax,[status] |
mov [prev_status],eax |
mov eax,53 |
mov ebx,6 |
mov ecx,[socket] |
int 0x40 |
mov [status],eax |
cmp [prev_status],4 |
jge no_send |
cmp [status],4 |
jne no_send |
mov [onoff],1 |
call send_request |
no_send: |
call print_status |
cmp [prev_status],4 |
jne no_close |
cmp [status],4 ; connection closed by server |
jbe no_close ; respond to connection close command |
; draw page |
call read_incoming_data |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
int 0x40 |
call draw_page |
mov [onoff],0 |
no_close: |
jmp still |
red: ; redraw |
call draw_window |
jmp still |
key: ; key |
mov eax,2 ; just read it and ignore |
int 0x40 |
shr eax,8 |
cmp eax,184 |
jne no_down |
cmp [display_from],25 |
jb no_down |
sub [display_from],25 |
call display_page |
no_down: |
cmp eax,183 |
jne no_up |
add [display_from],25 |
call display_page |
no_up: |
jmp still |
button: ; button |
;dps <"Button pressed",13,10> |
mov eax,17 ; get id |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jne noclose |
;dps "Closing socket before exit... " |
mov eax, 53 |
mov ebx, 8 |
mov ecx, [socket] |
int 0x40 |
;dpd eax |
;dps <13,10> |
exit: |
or eax,-1 ; close this program |
int 0x40 |
noclose: |
cmp ah,31 |
jne noup |
sub [display_from],20 |
call display_page |
jmp still |
noup: |
cmp ah,32 |
jne nodown |
add [display_from],20 |
call display_page |
jmp still |
nodown: |
cmp ah, 10 ; Enter url |
jne nourl |
mov [addr],dword document_user |
mov [ya],dword 38 |
mov [len],dword URLMAXLEN |
mov ecx,[len] |
mov edi,[addr] |
mov al,' ' |
rep stosb |
call print_text |
mov edi,[addr] |
f11: |
mov eax,10 |
int 0x40 |
cmp eax,2 ; key? |
jz fbu |
jmp still |
fbu: |
mov eax,2 |
int 0x40 ; get key |
shr eax,8 |
cmp eax,8 |
jnz nobs |
cmp edi,[addr] |
jz f11 |
sub edi,1 |
mov [edi],byte ' ' |
call print_text |
jmp f11 |
nobs: |
cmp eax, dword 10 |
je retkey |
cmp eax, dword 13 |
je retkey |
cmp eax,dword 31 |
jbe f11 |
; Removed in v0.4 |
; cmp eax,dword 95 |
; jb keyok |
; sub eax,32 |
keyok: |
mov [edi],al |
call print_text |
add edi,1 |
mov esi,[addr] |
add esi,URLMAXLEN |
cmp esi,edi |
jnz f11 |
jmp still |
retkey: |
mov ah, 22 ; start load |
nourl: |
call socket_commands ; opens or closes the connection |
jmp still |
;**************************************************************************** |
; Function |
; send_request |
; |
; Description |
; Transmits the GET request to the server. |
; This is done as GET then URL then HTTP/1.0',13,10,13,10 in 3 packets |
; |
;**************************************************************************** |
send_request: |
pusha |
mov eax,53 ; 'GET ' |
mov ebx,7 |
mov ecx,[socket] |
mov edx,4 |
mov esi,string0 |
int 0x40 |
mov edx,0 |
next_edx: |
; Determine the length of the url to send in the GET request |
inc edx |
cmp [edx+document],byte ' ' |
jne next_edx |
mov eax,53 ; document_user |
mov ebx,7 |
mov ecx,[socket] |
mov esi,document |
int 0x40 |
mov eax,53 ; ' HTTP/1.0 .. ' |
mov ebx,7 |
mov ecx,[socket] |
mov edx,stringh_end-stringh |
mov esi,stringh |
int 0x40 |
popa |
ret |
;**************************************************************************** |
; Function |
; print_status |
; |
; Description |
; displays the socket/data received status information |
; |
;**************************************************************************** |
print_status: |
pusha |
mov eax,26 |
mov ebx,9 |
int 0x40 |
cmp eax,[nextupdate] |
jb status_return |
add eax,25 |
mov [nextupdate],eax |
mov eax,13 |
mov ebx,5*65536+100 |
mov ecx,[winys] |
shl ecx,16 |
add ecx,-18*65536+10 |
mov edx,0xffffff |
int 0x40 |
mov eax,47 |
mov ebx,3*65536 |
mov ecx,[status] |
mov edx,12*65536-18 |
add edx,[winys] |
mov esi,0x000000 |
int 0x40 |
mov eax,47 |
mov ebx,6*65536 |
mov ecx,[pos] |
mov edx,40*65536-18 |
add edx,[winys] |
mov esi,0x000000 |
int 0x40 |
status_return: |
popa |
ret |
;**************************************************************************** |
; Function |
; read_incoming_data |
; |
; Description |
; receive the web page from the server, storing it without processing |
; |
;**************************************************************************** |
read_incoming_data: |
cmp [onoff],1 |
je rid |
ret |
rid: |
mov ecx,-1 |
newbyteread: |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socket] |
int 0x40 |
cmp eax,0 |
je no_more_data |
read_more: |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socket] |
int 0x40 |
yesm: |
inc [pos] |
mov ecx,[pos] |
mov [0x10000+ecx],bl |
call print_status |
cmp eax,0 |
jne read_more |
mov eax,5 |
mov ebx,50 |
int 0x40 |
jmp newbyteread |
no_more_data: |
ret |
;**************************************************************************** |
; Function |
; draw_page |
; |
; Description |
; parses the web page data, storing displayable data at 0x20000 |
; and attributes at 0x30000. It then calls display_page to render |
; the data |
; |
;**************************************************************************** |
draw_page: |
pusha |
mov esi,0 |
mov [command_on_off],0 |
newlettercheck: |
movzx eax,byte [esi+0x10000] |
cmp al,'<' |
jne no_c_on |
mov [command_on_off],1 |
no_c_on: |
cmp al,'>' |
jne no_c_off |
mov [command_on_off],0 |
no_c_off: |
cmp [command_on_off],0 |
je no_lower_case |
cmp eax,96 |
jg no_lower_case |
cmp eax,65 |
jb no_lower_case |
add eax,32 |
no_lower_case: |
mov [esi+0x10000],al |
inc esi |
cmp esi,[pos] |
jbe newlettercheck |
mov edi,0x30000 |
mov ecx,0x10000 |
mov al,0 |
cld |
rep stosb |
mov [text_type],1 |
mov [command_on_off],0 |
mov esi,0 |
mov ecx,[pos] |
; search for double lf |
find_dlf: |
cmp [0x10000+esi-4],dword 0x0d0a0d0a |
je found_dlf |
cmp [0x10000+esi-4],dword 0x0a0d0a0d |
je found_dlf |
cmp [0x10000+esi-2],word 0x0d0d |
je found_dlf |
cmp [0x10000+esi-2],word 0x0a0a |
je found_dlf |
cmp esi,5500 |
je found_dlf |
inc esi |
jmp find_dlf |
found_dlf: |
newbyte: |
mov al,[esi+0x10000] |
cmp al,'<' |
jne no_command_on |
mov [command_on_off],1 |
no_command_on: |
cmp al,'>' |
jne no_command_off |
mov [command_on_off],0 |
jmp byte_done |
no_command_off: |
mov eax,[esi+0x10000] ; <!-- |
cmp eax,'<!--' |
jne no_com2_start |
mov [com2],1 |
no_com2_start: |
mov ax,[esi+0x10000] ; --> |
cmp ax,'->' |
jne no_com2_end |
mov [com2],0 |
inc esi |
jmp byte_done |
no_com2_end: |
mov eax,[esi+0x10000] ; <script |
cmp eax,'<scr' |
jne no_script_start |
mov [script],1 |
no_script_start: |
mov eax,[esi+0x10000] ; /script> |
cmp eax,'</sc' |
jne no_script_end |
mov [script],0 |
inc esi |
jmp byte_done |
no_script_end: |
cmp [command_on_off],0 |
jne no_print |
cmp [com2],0 |
jne no_print |
cmp [script],0 |
jne no_print |
mov al,[esi+0x10000] ; & |
cmp al,'&' |
jne no_nbsp |
newsps: |
inc esi |
mov al,[esi+0x10000] ; |
cmp al,';' |
jne newsps |
jmp byte_done |
no_nbsp: |
cmp al,13 |
jne no_lb |
jmp byte_done |
no_lb: |
cmp al,10 |
jne no_lf |
jmp byte_done |
no_lf: |
mov ebx,[pagey] |
imul ebx,[pagexs] |
add ebx,[pagex] |
add ebx,0x20000 |
and eax,0xff |
cmp eax,31 |
jbe byte_done |
cmp [lastletter],al |
jne letter_ok |
cmp al,' ' |
je byte_done |
letter_ok: |
mov [ebx],al |
mov dl,[text_type] |
mov [ebx+0x10000],dl |
mov [pageyinc],0 |
mov [lastletter],al |
inc [pagex] |
mov ebx,[pagex] |
cmp ebx,[pagexs] |
jb byte_done |
mov [pagex],0 |
inc [pagey] |
jmp byte_done |
no_print: |
; HTML -COMMAND |
mov ax,[esi+0x10000] ; b> bold |
cmp ax,'b>' |
jne no_bold_start |
mov [text_type],2 |
no_bold_start: |
mov eax,[esi+0x10000] ; /b bold end |
cmp eax,'</b>' |
jne no_bold_end |
mov [text_type],1 |
add esi,2 |
no_bold_end: |
mov ax,[esi+0x10000] ; <a |
cmp ax,'a ' |
jne no_link_start |
mov [text_type],128 |
add esi,2 |
no_link_start: |
mov ax,[esi+0x10000] ; /a |
cmp ax,'/a' |
jne no_link_end2 |
mov [text_type],1 |
add esi,0 |
no_link_end2: |
mov ax,[esi+0x10000] |
cmp ax,'br' |
jne no_br |
call linefeed |
inc esi |
no_br: |
mov ax,[esi+0x10000] |
cmp ax,'td' |
jne no_td |
call linefeed |
inc esi |
no_td: |
mov eax,[esi+0x10000] |
cmp eax,'tabl' |
jne no_table |
call linefeed |
add esi,3 |
no_table: |
byte_done: |
inc esi |
cmp esi,[pos] |
jbe newbyte |
mov [display_from],0 |
call display_page |
popa |
ret |
;**************************************************************************** |
; Function |
; linefeed |
; |
; Description |
; |
; |
;**************************************************************************** |
linefeed: |
cmp [pageyinc],2 |
jge nolf |
mov [pagex],0 |
inc [pagey] |
inc [pageyinc] |
nolf: |
ret |
;**************************************************************************** |
; Function |
; display_page |
; |
; Description |
; Renders the text decoded by draw_page |
; |
;**************************************************************************** |
display_page: |
pusha |
mov eax,0 |
mov ebx,0 |
newpxy: |
push eax |
push ebx |
mov eax,13 ; background for letter |
mov ebx,[esp+4] |
imul ebx,6 |
add ebx,[dpx] |
shl ebx,16 |
add ebx,6 |
mov ecx,[esp+0] |
imul ecx,10 |
add ecx,[dpy] |
shl ecx,16 |
add ecx,10 |
mov edx,0xffffff |
int 0x40 |
mov eax,4 |
mov ebx,[esp+4] |
imul ebx,6 |
add ebx,[dpx] |
shl ebx,16 |
mov bx,[esp+0] |
imul bx,10 |
add bx,word [dpy] |
mov esi,[esp] |
imul esi,[pagexs] |
add esi,[esp+4] |
mov edx,[display_from] |
imul edx,[pagexs] |
add edx,0x20000 |
add edx,esi |
movzx ecx,byte [edx+0x10000] |
cmp ecx,1 |
jne noecx1 |
mov ecx,0x000000 |
noecx1: |
movzx ecx,byte [edx+0x10000] |
cmp ecx,2 |
jne noecx2 |
mov ecx,0xff0000 |
noecx2: |
cmp ecx,128 |
jne noecx128 |
mov ecx,0x0000ff |
noecx128: |
mov esi,1 |
int 0x40 |
pop ebx |
pop eax |
inc eax |
cmp eax,[pagexs] |
jb newpxy |
mov eax,0 |
inc ebx |
cmp ebx,30 |
jb newpxy |
popa |
ret |
;**************************************************************************** |
; Function |
; socket_commands |
; |
; Description |
; opens or closes the socket |
; |
;**************************************************************************** |
socket_commands: |
cmp ah,22 ; open socket |
jnz tst3 |
; Clear all page memory |
mov edi,0x10000 |
mov ecx,0x30000 |
mov al,0 |
cld |
rep stosb |
; Parse the entered url |
call parse_url |
; Get a free port number |
mov ecx, 1000 ; local port starting at 1000 |
getlp1: |
inc ecx |
push ecx |
mov eax, 53 |
mov ebx, 9 |
int 0x40 |
pop ecx |
cmp eax, 0 ; is this local port in use? |
jz getlp1 ; yes - so try next |
mov eax,53 |
mov ebx,5 |
mov edx,80 |
mov esi,dword [server_ip] |
mov edi,1 |
int 0x40 |
mov [socket], eax |
mov [pos],0 |
mov [pagex],0 |
mov [pagey],0 |
mov [pagexs],80 |
mov [command_on_off],0 |
ret |
tst3: |
cmp ah,24 ; close socket |
jnz no_24 |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
int 0x40 |
call draw_page |
ret |
no_24: |
ret |
;**************************************************************************** |
; Function |
; parse_url |
; |
; Description |
; parses the full url typed in by the user into a web address ( that |
; can be turned into an IP address by DNS ) and the page to display |
; DNS will be used to translate the web address into an IP address, if |
; needed. |
; url is at document_user and will be space terminated. |
; web address goes to webAddr and is space terminated. |
; ip address goes to server_ip |
; page goes to document and is space terminated. |
; |
; Supported formats: |
; <protocol://>address<page> |
; <protocol> is optional, removed and ignored - only http supported |
; <address> is required. It can be an ip address or web address |
; <page> is optional and must start with a leading / character |
; |
;**************************************************************************** |
parse_url: |
; First, reset destination variables |
cld |
mov al, ' ' |
mov edi, document |
mov ecx,URLMAXLEN |
rep stosb |
mov edi, webAddr |
mov ecx,URLMAXLEN |
rep stosb |
mov al, '/' |
mov [document], al |
mov esi, document_user |
; remove any leading protocol text |
mov ecx, URLMAXLEN |
mov ax, '//' |
pu_000: |
cmp [esi], byte ' ' ; end of text? |
je pu_002 ; yep, so not found |
cmp word [esi], ax |
je pu_001 ; Found it, so esi+2 is start |
inc esi |
loop pu_000 |
pu_002: |
; not found, so reset esi to start |
mov esi, document_user -2 |
pu_001: |
add esi, 2 |
mov ebx, esi ; save address of start of web address |
mov edi, document_user + URLMAXLEN ; end of string |
; look for page delimiter - it's a '/' character |
pu_003: |
cmp [esi], byte ' ' ; end of text? |
je pu_004 ; yep, so none found |
cmp esi, edi ; end of string? |
je pu_004 ; yep, so none found |
cmp [esi], byte '/' ; delimiter? |
je pu_005 ; yep - process it |
inc esi |
jmp pu_003 |
pu_005: |
; copy page to document address |
; esi = delimiter |
push esi |
inc esi |
mov ecx, edi ; end of document_user |
mov edi, document |
cld |
pu_006: |
movsb |
cmp esi, ecx |
je pu_007 ; end of string? |
cmp [esi], byte ' ' ; end of text |
je pu_007 |
jmp pu_006 |
pu_007: |
pop esi ; point esi to '/' delimiter |
pu_004: |
; copy web address to webAddr |
; start in ebx, end in esi-1 |
mov ecx, esi |
mov esi, ebx |
mov edi, webAddr |
cld |
pu_008: |
movsb |
cmp esi, ecx |
je pu_009 |
jmp pu_008 |
pu_009: |
; For debugging, display resulting strings |
if DEBUGGING_STATE = DEBUGGING_ENABLED |
mov esi, document_user |
call debug_print_string |
mov esi, webAddr |
call debug_print_string |
mov esi, document |
call debug_print_string |
end if |
; Look up the ip address, or was it specified? |
mov al, [webAddr] |
cmp al, '0' |
jb pu_010 ; Resolve address |
cmp al, '9' |
ja pu_010 ; Resolve address |
if DEBUGGING_STATE = DEBUGGING_ENABLED |
mov esi, str2 ; print gotip |
call debug_print_string |
end if |
; Convert address |
mov esi,webAddr-1 |
mov edi,server_ip |
xor eax,eax |
ip1: |
inc esi |
cmp [esi],byte '0' |
jb ip2 |
cmp [esi],byte '9' |
jg ip2 |
imul eax,10 |
movzx ebx,byte [esi] |
sub ebx,48 |
add eax,ebx |
jmp ip1 |
ip2: |
mov [edi],al |
xor eax,eax |
inc edi |
cmp edi,server_ip+3 |
jbe ip1 |
jmp pu_011 |
pu_010: |
if DEBUGGING_STATE = DEBUGGING_ENABLED |
mov esi, str1 ; print resolving |
call debug_print_string |
end if |
; Resolve Address |
call translateData ; Convert domain & DNS IP address |
call resolveDomain ; get ip address |
if DEBUGGING_STATE = DEBUGGING_ENABLED |
mov esi, str3 |
call debug_print_string |
end if |
pu_011: |
; Done |
ret |
;*************************************************************************** |
; Function |
; translateData |
; |
; Description |
; Coverts the domain name and DNS IP address typed in by the user into |
; a format suitable for the IP layer. |
; |
; The ename, in query, is converted and stored in dnsMsg |
; |
;*************************************************************************** |
translateData: |
; first, get the IP address of the DNS server |
; Then, build up the request string. |
; Build the request string |
mov eax, 0x00010100 |
mov [dnsMsg], eax |
mov eax, 0x00000100 |
mov [dnsMsg+4], eax |
mov eax, 0x00000000 |
mov [dnsMsg+8], eax |
; domain name goes in at dnsMsg+12 |
mov esi, dnsMsg + 12 ; location of label length |
mov edi, dnsMsg + 13 ; label start |
mov edx, webAddr |
mov ecx, 12 ; total string length so far |
td002: |
mov [esi], byte 0 |
inc ecx |
td0021: |
mov al, [edx] |
cmp al, ' ' |
je td001 ; we have finished the string translation |
cmp al, '.' ; we have finished the label |
je td004 |
inc byte [esi] |
inc ecx |
mov [edi], al |
inc edi |
inc edx |
jmp td0021 |
td004: |
mov esi, edi |
inc edi |
inc edx |
jmp td002 |
; write label len + label text |
td001: |
mov [edi], byte 0 |
inc ecx |
inc edi |
mov [edi], dword 0x01000100 |
add ecx, 4 |
mov [dnsMsgLen], ecx |
ret |
;*************************************************************************** |
; Function |
; resolveDomain |
; |
; Description |
; Sends a question to the dns server |
; works out the IP address from the response from the DNS server |
; |
;*************************************************************************** |
resolveDomain: |
; Get a free port number |
mov ecx, 1000 ; local port starting at 1000 |
getlp: |
inc ecx |
push ecx |
mov eax, 53 |
mov ebx, 9 |
int 0x40 |
pop ecx |
cmp eax, 0 ; is this local port in use? |
jz getlp ; yes - so try next |
; First, open socket |
mov eax, 53 |
mov ebx, 0 |
mov edx, 53 ; remote port - dns |
mov esi, dword [dns_ip] |
int 0x40 |
mov [socketNum], eax |
; write to socket ( request DNS lookup ) |
mov eax, 53 |
mov ebx, 4 |
mov ecx, [socketNum] |
mov edx, [dnsMsgLen] |
mov esi, dnsMsg |
int 0x40 |
; Setup the DNS response buffer |
mov eax, dnsMsg |
mov [dnsMsgLen], eax |
; now, we wait for |
; UI redraw |
; UI close |
; or data from remote |
ctr001: |
mov eax,10 ; wait here for event |
int 0x40 |
cmp eax,1 ; redraw request ? |
je ctr003 |
cmp eax,2 ; key in buffer ? |
je ctr004 |
cmp eax,3 ; button in buffer ? |
je ctr005 |
; Any data in the UDP receive buffer? |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
int 0x40 |
cmp eax, 0 |
je ctr001 |
; we have data - this will be the response |
ctr002: |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte - block (high byte) |
; Store the data in the response buffer |
mov eax, [dnsMsgLen] |
mov [eax], bl |
inc dword [dnsMsgLen] |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
int 0x40 ; any more data? |
cmp eax, 0 |
jne ctr002 ; yes, so get it |
; close socket |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
int 0x40 |
mov [socketNum], dword 0xFFFF |
; Now parse the message to get the host IP |
; Man, this is complicated. It's described in |
; RFC 1035 |
if DEBUGGING_STATE = DEBUGGING_ENABLED |
mov esi, str4 |
call debug_print_string |
end if |
; 1) Validate that we have an answer with > 0 responses |
; 2) Find the answer record with TYPE 0001 ( host IP ) |
; 3) Finally, copy the IP address to the display |
; Note: The response is in dnsMsg |
; The end of the buffer is pointed to by [dnsMsgLen] |
; Clear the IP address text |
mov [server_ip], dword 0 |
mov esi, dnsMsg |
; Is this a response to my question? |
mov al, [esi+2] |
and al, 0x80 |
cmp al, 0x80 |
jne ctr002a |
; Were there any errors? |
mov al, [esi+3] |
and al, 0x0F |
cmp al, 0x00 |
jne ctr002a |
; Is there ( at least 1 ) answer? |
mov ax, [esi+6] |
cmp ax, 0x00 |
je ctr002a |
; Header validated. Scan through and get my answer |
if DEBUGGING_STATE = DEBUGGING_ENABLED |
pusha |
mov esi, str4 |
call debug_print_string |
popa |
end if |
add esi, 12 ; Skip to the question field |
; Skip through the question field |
call skipName |
add esi, 4 ; skip past the questions qtype, qclass |
ctr002z: |
; Now at the answer. There may be several answers, |
; find the right one ( TYPE = 0x0001 ) |
call skipName |
mov ax, [esi] |
cmp ax, 0x0100 ; Is this the IP address answer? |
jne ctr002c |
; Yes! Point esi to the first byte of the IP address |
add esi, 10 |
mov eax, [esi] |
mov [server_ip], eax |
ret |
ctr002c: ; Skip through the answer, move to the next |
add esi, 8 |
movzx eax, byte [esi+1] |
mov ah, [esi] |
add esi, eax |
add esi, 2 |
; Have we reached the end of the msg? |
; This is an error condition, should not happen |
cmp esi, [dnsMsgLen] |
jl ctr002z ; Check next answer |
jmp ctr002a ; abort |
ctr002a: |
jmp ctr001 |
ctr003: ; redraw |
call draw_window |
jmp ctr001 |
ctr004: ; key |
mov eax,2 ; just read it and ignore |
int 0x40 |
jmp ctr001 |
ctr005: ; button |
mov eax,17 ; get id |
int 0x40 |
mov dl, ah |
; close socket |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
int 0x40 |
cmp dl, 1 |
je exit |
mov [socketNum], dword 0xFFFF |
mov [server_ip], dword 0 |
ret |
;*************************************************************************** |
; Function |
; skipName |
; |
; Description |
; Increment esi to the first byte past the name field |
; Names may use compressed labels. Normally do. |
; RFC 1035 page 30 gives details |
; |
;*************************************************************************** |
skipName: |
mov al, [esi] |
cmp al, 0 |
je sn_exit |
and al, 0xc0 |
cmp al, 0xc0 |
je sn001 |
movzx eax, byte [esi] |
inc eax |
add esi, eax |
jmp skipName |
sn001: |
add esi, 2 ; A pointer is always at the end |
ret |
sn_exit: |
inc esi |
ret |
if DEBUGGING_STATE = DEBUGGING_ENABLED |
;**************************************************************************** |
; Function |
; debug_print_string |
; |
; Description |
; prints a string to the debug board, in quotes |
; |
; esi holds ptr to msg to display, which is space or 0 terminated |
; |
; Nothing preserved; I'm assuming a pusha/popa is done before calling |
; |
;**************************************************************************** |
debug_print_string: |
push esi |
mov cl, '"' |
mov eax,63 |
mov ebx, 1 |
int 0x40 |
pop esi |
dps_000: |
mov cl, [esi] |
cmp cl, 0 |
je dps_exit |
cmp cl, ' ' |
je dps_exit |
jmp dps_001 |
dps_exit: |
mov cl, '"' |
mov eax,63 |
mov ebx, 1 |
int 0x40 |
mov cl, 13 |
mov eax,63 |
mov ebx, 1 |
int 0x40 |
mov cl, 10 |
mov eax,63 |
mov ebx, 1 |
int 0x40 |
ret |
dps_001: |
mov eax,63 |
mov ebx, 1 |
push esi |
int 0x40 |
pop esi |
inc esi |
jmp dps_000 |
end if |
;**************************************************************************** |
; Function |
; print_text |
; |
; Description |
; display the url (full path) text |
; |
;**************************************************************************** |
print_text: |
; Draw a bar to blank out previous text |
mov eax,13 |
mov ebx,30*65536+URLMAXLEN*6 ; 50 should really be [len], and 103 [xa] |
mov ecx,[ya] |
shl ecx,16 |
mov cx,9 |
mov edx,0xFFFFFF |
int 0x40 |
; write text |
mov eax,4 |
mov ebx,30*65536 |
add ebx,[ya] |
mov ecx,0x000000 |
mov edx,[addr] |
mov esi,URLMAXLEN |
int 0x40 |
ret |
; ********************************************* |
; ******* 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,50*65536+550 ; [x start] *65536 + [x size] |
mov ecx,50*65536+400 ; [y start] *65536 + [y size] |
mov edx,0x03ffffff ; color of work area RRGGBB,8->color gl |
mov esi,0x805080d0 ; color of grab bar RRGGBB,8->color gl |
mov edi,0x005080d0 ; 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,0x00ddeeff ; color of text RRGGBB |
mov edx,labelt ; pointer to text beginning |
mov esi,labellen-labelt ; text length |
int 0x40 |
mov esi, URLMAXLEN ; URL |
mov eax,4 ; function 4 : write text to window |
mov ebx,30*65536+38 ; [x start] *65536 + [y start] |
mov ecx,0x000000 ; color of text RRGGBB |
mov edx,document_user ; pointer to text beginning |
int 0x40 |
mov eax,38 |
mov ebx,5*65536+545 |
mov ecx,60*65536+60 |
mov edx,0x000000 |
int 0x40 |
mov eax,38 |
mov ebx,5*65536+545 |
mov ecx,[winys] |
shl ecx,16 |
add ecx,[winys] |
sub ecx,26*65536+26 |
mov edx,0x000000 |
int 0x40 |
; RELOAD |
mov eax,8 ; function 8 : define and draw button |
mov ebx,388*65536+50 ; [x start] *65536 + [x size] |
mov ecx,34*65536+14 ; [y start] *65536 + [y size] |
mov edx,22 ; button id |
mov esi,0x5588dd ; button color RRGGBB |
int 0x40 |
; URL |
mov eax,8 ; function 8 : define and draw button |
mov ebx,10*65536+12 ; [x start] *65536 + [x size] |
mov ecx,34*65536+12 ; [y start] *65536 + [y size] |
mov edx,10 ; button id |
mov esi,0x5588dd ; button color RRGGBB |
int 0x40 |
; STOP |
mov eax,8 ; function 8 : define and draw button |
mov ebx,443*65536+50 ; [x start] *65536 + [x size] |
mov ecx,34*65536+14 ; [y start] *65536 + [y size] |
mov edx,24 ; button id |
mov esi,0x5588dd ; button color RRGGBB |
int 0x40 |
; BUTTON TEXT |
mov eax,4 ; function 4 : write text to window |
mov ebx,390*65536+38 ; [x start] *65536 + [y start] |
mov ecx,0xffffff ; color of text RRGGBB |
mov edx,button_text ; pointer to text beginning |
mov esi,20 ; text length |
int 0x40 |
call display_page |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
ret |
if DEBUGGING_STATE = DEBUGGING_ENABLED |
str1: db "Resolving...",0 |
str3: db "Resolved",0 |
str2: db "GotIP",0 |
str4: db "GotResponse",0 |
end if |
button_text db ' RELOAD STOP ' |
dpx dd 25 ; x - start of html page in pixels in window |
dpy dd 65 ; for y |
lastletter db 0 |
pageyinc dd 0 |
display_from dd 20 |
pos dd 0x0 |
pagex dd 0x0 |
pagey dd 0x0 |
pagexs dd 80 |
command_on_off dd 0x0 |
text_type db 1 |
com2 dd 0x0 |
script dd 0x0 |
socket dd 0x0 |
addr dd 0x0 |
ya dd 0x0 |
len dd 0x00 |
labelt: db 'HTTPC - PgUp/PgDown' |
labellen: |
server_ip: db 207,44,212,20 |
dns_ip: db 194,145,128,1 |
webAddr: times 128 db ' ' |
document_user: db 'Click on the button to the left to enter a URL',0 |
times 100 db 0x0 |
document: db '/' |
times 100 db ' ' |
string0: db 'GET ' |
stringh: db ' HTTP/1.0',13,10,13,10 |
stringh_end: |
status dd 0x0 |
prev_status dd 0x0 |
onoff dd 0x0 |
nextupdate: dd 0 |
winys: dd 400 |
dnsMsgLen: dd 0 |
socketNum: dd 0xFFFF |
dnsMsg: |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/httpc/trunk/macros.inc |
---|
0,0 → 1,265 |
; 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 { ; mike.dld |
if ~a 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 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/https/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm https.asm https |
@pause |
/programs/network/https/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm https.asm https |
@pause |
/programs/network/https/trunk/https.asm |
---|
0,0 → 1,1394 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; ; |
; Tiny HTTP Server v 0.4 for MenuetOS ; |
; ; |
; License GPL / See file COPYING for details. ; |
; Copyright 2003 Ville Turjanmaa ; |
; ; |
; Compile with FASM for Menuet ; |
; ; |
; Request /TinyStat for server statistics ; |
; Request /TinyBoard for server message board ; |
; ; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
version equ '0.4' |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; required os |
dd START ; program start |
dd I_END ; program image size |
dd 0x400000 ; required amount of memory |
dd 0x20000 |
dd 0,0 ; reserved=no extended header |
include 'lang.inc' |
include "macros.inc" |
; 0x0+ - program image |
; 0x1ffff - stack |
; 0x20000+ - message board |
; 0x100000+ - requested file |
filel: |
dd 0x0,0x0,50000/512,0x20000,0x70000 |
db '/rd/1/board.htm',0 |
files: |
dd 0x1,0x0,0x0,0x20000,0x70000 |
db '/rd/1/board.htm',0 |
START: ; start of execution |
mov eax,58 |
mov ebx,filel |
int 0x40 |
mov [board_size],ebx |
cmp eax,0 |
je board_found |
mov [board_size],board_end-board |
mov esi,board |
mov edi,0x20000 |
mov ecx,[board_size] |
cld |
rep movsb |
board_found: |
mov eax,58 |
mov ebx,files |
mov ecx,[board_size] |
mov [files+8],ecx |
int 0x40 |
mov [status],-1 |
mov [last_status],-2 |
call clear_input |
call draw_window ; at first, draw the window |
; call ops |
still: |
call check_status |
cmp [status],4 |
je start_transmission |
cmp [status],0 |
jne nnn |
cmp [server_active],1 |
jne nnn |
call ops |
nnn: |
mov eax,5 |
mov ebx,1 |
int 0x40 |
mov eax,11 |
int 0x40 |
call check_events |
jmp still |
reb: ; boot |
mov eax,18 |
mov ebx,1 |
int 0x40 |
jmp $ |
last_status dd 0x0 |
check_events: |
cmp eax,1 ; redraw request ? |
jz red |
cmp eax,2 ; key in buffer ? |
jz key |
cmp eax,3 ; button in buffer ? |
jz button |
ret |
red: ; redraw |
call draw_window |
ret |
key: ; Keys are not valid at this part of the |
mov eax,2 ; loop. Just read it and ignore |
int 0x40 |
ret |
button: ; button |
mov eax,17 ; get id |
int 0x40 |
cmp ah,1 ; close |
jnz tst2 |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
int 0x40 |
mov eax,-1 |
int 0x40 |
tst2: |
cmp ah,2 ; button id=2 ? |
jnz tst3 |
; open socket |
ops: |
mov eax,53 |
mov ebx,5 |
mov ecx,80 ; local port # - http |
mov edx,0 ; no remote port specified |
mov esi,0 ; no remote ip specified |
mov edi,0 ; PASSIVE open |
int 0x40 |
mov [socket], eax |
mov [posy],1 |
mov [posx],0 |
call check_for_incoming_data |
call clear_input |
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 |
close_socket: |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
int 0x40 |
mov eax,5 |
mov ebx,2 |
int 0x40 |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
int 0x40 |
cmp [server_active],1 |
jne no_re_open |
mov eax,53 |
mov ebx,5 |
mov ecx,80 ; local port # - http |
mov edx,0 ; no remote port specified |
mov esi,0 ; no remote ip specified |
mov edi,0 ; PASSIVE open |
int 0x40 |
mov [socket], eax |
no_re_open: |
mov edi,input_text+256*15+1 |
mov [edi+2],dword ': :' |
call set_time |
mov edi,input_text+256*16+1 |
mov [edi+2],dword '. .' |
call set_date |
mov eax,[documents_served] |
mov ecx,9 |
mov edi,input_text+256*15+12 |
call set_value |
mov eax,[bytes_transferred] |
mov ecx,9 |
mov edi,input_text+256*16+12 |
call set_value |
call draw_data |
mov esp,0x1ffff |
jmp still |
no4: |
cmp ah,6 ; read directory |
je read_string |
ret |
clear_input: |
mov edi,input_text |
mov eax,0 |
mov ecx,256*30 |
cld |
rep stosb |
ret |
retries dd 50 |
start_transmission: |
mov [posy],1 |
mov [posx],0 |
call clear_input |
mov [retries],50 |
wait_for_data: |
call check_for_incoming_data |
cmp [input_text+256+1],dword 'GET ' |
je data_received |
cmp [input_text+256+1],dword 'POST' |
je data_received |
mov eax,5 |
mov ebx,1 |
int 0x40 |
dec [retries] |
jnz wait_for_data |
jmp no_http_request |
data_received: |
mov eax,0x100000 |
mov ebx,0x2f0000 / 512 |
call read_file |
call wait_for_empty_slot |
call send_header |
mov [filepos],0x100000 |
mov [fileadd],700 |
call check_status |
call draw_data |
newblock: |
call wait_for_empty_slot |
mov edx,[fileadd] |
cmp edx,[file_left] |
jbe file_size_ok |
mov edx,[file_left] |
file_size_ok: |
sub [file_left],edx |
; write to socket |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov esi,[filepos] |
int 0x40 |
mov eax,esi |
add eax,edx |
sub eax,0x100000 |
call display_progress |
mov edx,[fileadd] |
add [filepos],edx |
cmp [file_left],0 |
jg newblock |
no_http_request: |
jmp close_socket |
filepos dd 0x100000 |
fileadd dd 0x1 |
filesize dd 0x0 |
file_left dd 0x0 |
wait_for_empty_slot: |
pusha |
wait_more: |
; rdtsc |
; mov ecx,eax |
; add ecx,1000000 |
; wr: |
; rdtsc |
; cmp eax,ecx |
; jb wr |
mov eax,5 |
mov ebx,1 |
int 0x40 |
mov eax,11 |
int 0x40 |
call check_events |
mov eax,53 |
mov ebx,255 |
mov ecx,103 |
int 0x40 |
cmp eax,0 |
je no_wait_more |
jmp wait_more |
no_wait_more: |
popa |
ret |
display_progress: |
pusha |
mov edi,eax |
mov eax,13 |
mov ebx,115*65536+8*6 |
mov ecx,178*65536+10 |
mov edx,0xffffff |
int 0x40 |
mov eax,47 |
mov ebx,8*65536 |
mov ecx,edi |
mov edx,115*65536+178 |
mov esi,0x000000 |
int 0x40 |
popa |
ret |
send_header: |
pusha |
mov eax,53 ; send response and file length |
mov ebx,7 |
mov ecx,[socket] |
mov edx,h_len-html_header |
mov esi,html_header |
int 0x40 |
mov eax,53 ; send file type |
mov ebx,7 |
mov ecx,[socket] |
mov edx,[type_len] |
mov esi,[file_type] |
int 0x40 |
popa |
ret |
fileinfo dd 0,0,1,0x100000,0xf0000 |
getf db '/RD/1/' |
times 50 db 0 |
wanted_file: times 100 db 0 |
getflen dd 6 |
make_room: |
pusha |
mov edx,ecx |
mov esi,0x20000 |
add esi,[board_size] |
mov edi,esi |
add edi,edx |
mov ecx,[board_size] |
sub ecx,board1-board |
inc ecx |
std |
rep movsb |
cld |
popa |
ret |
from_i dd 0x0 |
from_len dd 0x0 |
message dd 0x0 |
message_len dd 0x0 |
read_file: ; start of execution |
mov [fileinfo+12],eax |
mov [fileinfo+8],ebx |
mov [file_type],unk |
mov [type_len],unkl-unk |
mov [filename+40*2+6],dword 'UNK ' |
cmp [input_text+256+1],dword 'POST' |
je yes_new_message |
cmp [input_text+256+11],dword 'oard' ; server board message |
jne no_server_message_2 |
yes_new_message: |
mov eax,58 |
mov ebx,filel |
int 0x40 |
mov [board_size],ebx |
cmp [input_text+256+1],dword 'POST' |
jne no_new_message |
mov edi,bsmt |
call set_time |
mov edi,bsmd |
call set_date |
call check_for_incoming_data |
mov esi,input_text+256 ; from |
newfroms: |
inc esi |
cmp esi,input_text+256*20 |
je no_server_message_2 |
cmp [esi],dword 'from' |
jne newfroms |
add esi,5 |
mov [from_i],esi |
mov edx,0 |
name_new_len: |
cmp [esi+edx],byte 13 |
je name_found_len |
cmp [esi+edx],byte '&' |
je name_found_len |
cmp edx,1000 |
je name_found_len |
inc edx |
jmp name_new_len |
name_found_len: |
mov [from_len],edx |
mov esi,input_text+256 |
newmessages: |
inc esi |
cmp esi,input_text+256*20 |
je no_server_message_2 |
cmp [esi],dword 'sage' |
jne newmessages |
add esi,5 |
mov [message],esi |
mov edx,0 |
new_len: |
inc edx |
cmp [esi+edx],byte ' ' |
je found_len |
cmp [esi+edx],byte 13 |
jbe found_len |
cmp edx,input_text+5000 |
je found_len |
jmp new_len |
found_len: |
mov [message_len],edx |
mov edx,0 |
change_letters: |
cmp [esi+edx],byte '+' |
jne no_space |
mov [esi+edx],byte ' ' |
no_space: |
cmp [esi+edx+1],word '0D' |
jne no_br |
mov [esi+edx],dword '<br>' |
mov [esi+edx+4],word ' ' |
no_br: |
cmp [esi+edx],byte '%' |
jne no_ascii |
movzx eax,byte [esi+edx+2] |
sub eax,48 |
cmp eax,9 |
jbe eax_ok |
sub eax,7 |
eax_ok: |
movzx ebx,byte [esi+edx+1] |
sub ebx,48 |
cmp ebx,9 |
jbe ebx_ok |
sub ebx,7 |
ebx_ok: |
imul ebx,16 |
add ebx,eax |
mov [esi+edx],bl |
mov [esi+edx+1],word ' ' |
add edx,2 |
no_ascii: |
inc edx |
cmp edx,[message_len] |
jbe change_letters |
mov edx,board1e-board1 + board2e-board2 + board3e-board3 |
add edx,[from_len] |
add edx,[message_len] |
add [board_size],edx |
mov ecx,edx |
call make_room |
mov esi,board1 ; first part |
mov edi,0x20000 |
add edi,board1-board |
mov ecx,edx |
cld |
rep movsb |
mov esi,[from_i] ; name |
mov edi,0x20000 |
add edi,board1-board + board1e-board1 |
mov ecx,[from_len] |
cld |
rep movsb |
mov esi,board2 ; middle part |
mov edi,0x20000 |
add edi,board1-board + board1e-board1 |
add edi,[from_len] |
mov ecx,board2e-board2 |
cld |
rep movsb |
mov esi,[message] ; message |
mov edi,0x20000 |
add edi,board1-board + board1e-board1 +board2e-board2 |
add edi,[from_len] |
mov ecx,[message_len] |
cld |
rep movsb |
mov esi,board3 ; end part |
mov edi,0x20000 |
add edi,board1-board + board1e-board1 +board2e-board2 |
add edi,[from_len] |
add edi,[message_len] |
mov ecx,board3e-board3 |
cld |
rep movsb |
inc [board_messages] |
mov eax,[board_size] |
mov [files+8],eax |
mov eax,58 |
mov ebx,files |
int 0x40 |
no_new_message: |
mov esi,0x20000 |
mov edi,0x100000 |
mov ecx,[board_size] |
cld |
rep movsb |
mov ebx,[board_size] |
mov [file_type],htm |
mov [type_len],html-htm |
mov [filename+40*2+6],dword 'HTM ' |
jmp file_loaded |
no_server_message_2: |
cmp [input_text+256+9],dword 'ySta' ; server message |
jne no_server_message_1 |
mov edi,smt |
call set_time |
mov edi,smd |
call set_date |
mov eax,[documents_served] |
mov ecx,9 |
mov edi,sms+21 |
call set_value |
mov eax,[bytes_transferred] |
mov ecx,9 |
mov edi,smb+21 |
call set_value |
mov eax,[board_messages] |
mov ecx,9 |
mov edi,smm+21 |
call set_value |
mov eax,[board_size] |
mov ecx,9 |
mov edi,smz+21 |
call set_value |
mov esi,sm |
mov edi,0x100000 |
mov ecx,sme-sm |
cld |
rep movsb |
mov ebx,sme-sm |
mov [file_type],htm |
mov [type_len],html-htm |
mov [filename+40*2+6],dword 'HTM ' |
jmp file_loaded |
no_server_message_1: |
mov esi,input_text+256+6 |
cmp [input_text+256+1],dword 'GET ' |
jne no_new_let |
mov edi,wanted_file |
cld |
new_let: |
cmp [esi],byte ' ' |
je no_new_let |
cmp edi,wanted_file+30 |
jge no_new_let |
movsb |
jmp new_let |
no_new_let: |
mov [edi+0],dword 0 |
mov [edi+4],dword 0 |
mov [edi+8],dword 0 |
cmp esi,input_text+256+6 |
jne no_index |
mov edi,wanted_file |
mov [edi+0],dword 'inde' |
mov [edi+4],dword 'x.ht' |
mov [edi+8],byte 'm' |
mov [edi+9],byte 0 |
add edi,9 |
mov [file_type],htm |
mov [type_len],html-htm |
mov [filename+40*2+6],dword 'HTM ' |
jmp html_file |
no_index: |
cmp [edi-3],dword 'htm'+0 |
je htm_header |
cmp [edi-3],dword 'HTM'+0 |
je htm_header |
jmp no_htm_header |
htm_header: |
mov [file_type],htm |
mov [type_len],html-htm |
mov [filename+40*2+6],dword 'HTM ' |
jmp found_file_type |
no_htm_header: |
cmp [edi-3],dword 'png'+0 |
je png_header |
cmp [edi-3],dword 'PNG'+0 |
je png_header |
jmp no_png_header |
png_header: |
mov [file_type],png |
mov [type_len],pngl-png |
mov [filename+40*2+6],dword 'PNG ' |
jmp found_file_type |
no_png_header: |
cmp [edi-3],dword 'gif'+0 |
je gif_header |
cmp [edi-3],dword 'GIF'+0 |
je gif_header |
jmp no_gif_header |
gif_header: |
mov [file_type],gif |
mov [type_len],gifl-gif |
mov [filename+40*2+6],dword 'GIF ' |
jmp found_file_type |
no_gif_header: |
cmp [edi-3],dword 'jpg'+0 |
je jpg_header |
cmp [edi-3],dword 'JPG'+0 |
je jpg_header |
jmp no_jpg_header |
jpg_header: |
mov [file_type],jpg |
mov [type_len],jpgl-jpg |
mov [filename+40*2+6],dword 'JPG ' |
jmp found_file_type |
no_jpg_header: |
cmp [edi-3],dword 'asm'+0 |
je txt_header |
cmp [edi-3],dword 'ASM'+0 |
je txt_header |
cmp [edi-3],dword 'txt'+0 |
je txt_header |
cmp [edi-3],dword 'TXT'+0 |
je txt_header |
jmp no_txt_header |
txt_header: |
mov [file_type],txt |
mov [type_len],txtl-txt |
mov [filename+40*2+6],dword 'TXT ' |
jmp found_file_type |
no_txt_header: |
html_file: |
found_file_type: |
mov edi,getf |
add edi,[getflen] |
mov esi,wanted_file |
mov ecx,40 |
cld |
rep movsb |
mov esi,getf |
mov edi,filename |
mov ecx,35 |
cld |
rep movsb |
mov [fileinfo+8],dword 1 ; file exists ? |
mov eax,58 |
mov ebx,fileinfo |
int 0x40 |
cmp eax,0 ; file not found - message |
je file_found |
mov edi,et |
call set_time |
mov edi,ed |
call set_date |
mov esi,fnf |
mov edi,0x100000 |
mov ecx,fnfe-fnf |
cld |
rep movsb |
mov ebx,fnfe-fnf |
mov [file_type],htm |
mov [type_len],html-htm |
mov [filename+40*2+6],dword 'HTM ' |
jmp file_not_found |
file_found: |
mov [fileinfo+8],dword 0x2f0000 / 512 ; read all of file |
mov eax,58 |
mov ebx,fileinfo |
int 0x40 |
file_not_found: |
file_loaded: |
and ebx,0x3fffff |
mov [filesize],ebx |
mov [file_left],ebx |
mov eax,ebx |
mov edi,c_l+5 |
mov ebx,10 |
newl: |
xor edx,edx |
div ebx |
mov ecx,edx |
add cl,48 |
mov [edi],cl |
dec edi |
cmp edi,c_l |
jge newl |
mov esi,c_l |
mov edi,filename+46 |
mov ecx,7 |
cld |
rep movsb |
inc [documents_served] |
mov eax,[filesize] |
add [bytes_transferred],eax |
call draw_data |
ret |
set_value: |
pusha |
add edi,ecx |
mov ebx,10 |
new_value: |
xor edx,edx |
div ebx |
add dl,48 |
mov [edi],dl |
dec edi |
loop new_value |
popa |
ret |
set_time: |
pusha |
mov eax,3 |
int 0x40 |
mov ecx,3 |
new_time_digit: |
mov ebx,eax |
and ebx,0xff |
shl ebx,4 |
shr bl,4 |
add bx,48*256+48 |
mov [edi],bh |
mov [edi+1],bl |
add edi,3 |
shr eax,8 |
loop new_time_digit |
popa |
ret |
set_date: |
pusha |
mov eax,29 |
int 0x40 |
mov ecx,3 |
add edi,6 |
new_date_digit: |
mov ebx,eax |
and ebx,0xff |
shl ebx,4 |
shr bl,4 |
add bx,48*256+48 |
mov [edi],bh |
mov [edi+1],bl |
sub edi,3 |
shr eax,8 |
loop new_date_digit |
popa |
ret |
check_for_incoming_data: |
pusha |
check: |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socket] |
int 0x40 |
cmp eax,0 |
je _ret_now |
new_data: |
mov eax,53 |
mov ebx,2 |
mov ecx,[socket] |
int 0x40 |
cmp eax,0 |
je _ret |
mov eax,53 |
mov ebx,3 |
mov ecx,[socket] |
int 0x40 |
cmp bl,10 |
jne no_lf |
inc [posy] |
mov [posx],0 |
jmp new_data |
no_lf: |
cmp bl,20 |
jb new_data |
inc [posx] |
cmp [posy],20 |
jbe yok |
mov [posy],1 |
yok: |
mov eax,[posy] |
imul eax,256 |
add eax,[posx] |
mov [input_text+eax],bl |
jmp new_data |
_ret: |
call draw_data |
mov eax,5 |
mov ebx,1 |
cmp [input_text+256+1],dword 'POST' |
jne no_ld |
mov ebx,50 |
no_ld: |
int 0x40 |
jmp check |
_ret_now: |
popa |
ret |
posy dd 1 |
posx dd 0 |
check_status: |
pusha |
mov eax,53 |
mov ebx,6 |
mov ecx,[socket] |
int 0x40 |
cmp eax,[status] |
je c_ret |
mov [status],eax |
add al,48 |
mov [text+12],al |
call draw_data |
c_ret: |
popa |
ret |
addr dd 0x0 |
ya dd 0x0 |
filename2: times 100 db 32 |
read_string: |
mov [addr],dword getf |
mov [ya],dword 139 |
mov edi,[addr] |
mov eax,0 |
mov ecx,30 |
cld |
rep stosb |
call print_text |
mov edi,[addr] |
f11: |
mov eax,10 |
int 0x40 |
cmp eax,2 |
jne read_done |
mov eax,2 |
int 0x40 |
shr eax,8 |
cmp eax,13 |
je read_done |
cmp eax,8 |
jnz nobsl |
cmp edi,[addr] |
jz f11 |
sub edi,1 |
mov [edi],byte 32 |
call print_text |
jmp f11 |
nobsl: |
mov [edi],al |
call print_text |
add edi,1 |
mov esi,[addr] |
add esi,30 |
cmp esi,edi |
jnz f11 |
read_done: |
push edi |
mov ecx,40 |
mov eax,32 |
cld |
rep stosb |
call print_text |
pop edi |
sub edi,[addr] |
mov [getflen],edi |
mov esi,getf |
mov edi,dirp+12 |
mov ecx,28 |
cld |
rep movsb |
jmp still |
print_text: |
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,0x000000 |
mov esi,23 |
int 0x40 |
popa |
ret |
; ********************************************* |
; ******* 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+480 ; [x start] *65536 + [x size] |
mov ecx,100*65536+215 ; [y start] *65536 + [y size] |
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] |
mov edx,2 ; button id |
mov esi,0x66aa66 ; button color RRGGBB |
int 0x40 |
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 |
mov esi,0xaa6666 ; button color RRGGBB |
int 0x40 |
mov eax,8 ; Enter directory |
mov ebx,(25)*65536+66 |
mov ecx,135*65536+15 |
mov edx,6 |
mov esi,0x3388dd |
int 0x40 |
mov eax,38 |
mov ebx,240*65536+240 |
mov ecx,22*65536+210 |
mov edx,0x6699cc ; 002288 |
int 0x40 |
mov eax,38 |
mov ebx,241*65536+241 |
mov ecx,22*65536+210 |
mov edx,0x336699 ; 002288 |
int 0x40 |
call draw_data |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
ret |
draw_data: |
pusha |
mov ebx,25*65536+35 ; draw info text with function 4 |
mov ecx,0x000000 |
mov edx,text |
mov esi,35 |
newline: |
pusha |
cmp ebx,25*65536+61 |
je now |
cmp ebx,25*65536+74 |
je now |
cmp ebx,25*65536+74+13*5 |
je now |
mov ecx,ebx |
mov bx,35*6 |
shl ecx,16 |
mov cx,9 |
mov eax,13 |
mov edx,0xffffff |
int 0x40 |
now: |
popa |
mov eax,4 |
int 0x40 |
add ebx,13 |
add edx,40 |
cmp [edx],byte 'x' |
jnz newline |
mov [input_text+0],dword 'RECE' |
mov [input_text+4],dword 'IVED' |
mov [input_text+8],dword ': ' |
mov ebx,255*65536+35 ; draw info text with function 4 |
mov ecx,0x000000 |
mov edx,input_text |
mov esi,35 |
mov edi,17 |
newline2: |
pusha |
mov ecx,ebx |
mov bx,35*6 |
shl ecx,16 |
mov cx,9 |
mov eax,13 |
mov edx,0xffffff |
int 0x40 |
popa |
mov eax,4 |
int 0x40 |
add ebx,10 |
add edx,256 |
dec edi |
jnz newline2 |
popa |
ret |
; DATA AREA |
status dd 0x0 |
text: |
db 'TCB status: x ' |
db ' ' |
db ' Activate server ' |
db ' Stop server ' |
db ' ' |
db 'Requests: /TinyStat -statistics ' |
db ' /TinyBoard -message board ' |
db ' ' |
dirp: |
db ' Files: /RD/1/ ' |
db ' ' |
filename: |
db ' ' |
db 'Size: ------- ' |
db 'Type: --- ' |
db 'x' ; <- END MARKER, DONT DELETE |
html_header: |
db 'HTTP/1.0 200 OK',13,10 |
db 'Server: MenuetOS HTTP Server',13,10 |
db 'Content-Length: ' |
c_l: db '000000',13,10 |
h_len: |
fnf: |
db '<body>' |
db '<pre>' |
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>" |
fnfe: |
sm: |
db '<body>' |
db '<pre>' |
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>' |
sme: |
documents_served dd 0x0 |
bytes_transferred dd 0x0 |
file_type dd 0 |
type_len dd 0 |
htm: db 'Content-Type: text/html',13,10,13,10 |
html: |
txt: db 'Content-Type: text/plain',13,10,13,10 |
txtl: |
png: db 'Content-Type: image/png',13,10,13,10 |
pngl: |
gif: db 'Content-Type: image/gif',13,10,13,10 |
gifl: |
jpg: db 'Content-Type: image/jpeg',13,10,13,10 |
jpgl: |
unk: db 'Content-Type: unknown/unknown',13,10,13,10 |
unkl: |
labelt: db 'Tiny http server ',version |
labellen: |
socket dd 0x0 |
server_active db 0x0 |
board: |
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=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 |
board1: |
db "<TR VALIGN=top>",13,10 |
db "<TD ALIGN=left width=80 bgcolor=f0f0f8><P>",13,10 |
db "<font size=3>",13,10 |
board1e: |
db "WebMaster",13,10 |
board2: |
db "</font>",13,10 |
db "<br><br><br>",13,10 |
db "<br><br><br><br>",13,10 |
bsmt: |
db "12.23.45<br>",13,10 |
bsmd: |
db "02.05.03",13,10 |
db "</P></TD>",13,10 |
db "<TD bgcolor=f0f0f8><P>",13,10 |
board2e: |
db "Assembly written messageboard from assembly written MenuetOS.<br>" |
db 13,10 |
board3: |
db "</P></TD></TR>",13,10,13,10 |
board3e: |
boardadd: |
db "</TABLE>",13,10 |
db "<br>",13,10 |
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=f0f0f8><P>",13,10 |
db "<form method=Post Action=/TinyBoard>",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 |
db "</HTML>",13,10 |
board_end: |
board_size dd 0x0 |
board_messages dd 0x0 |
input_text: |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/https/trunk/macros.inc |
---|
0,0 → 1,265 |
; 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 { ; mike.dld |
if ~a 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 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/ipc/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm ipc.asm ipc |
@pause |
/programs/network/ipc/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm ipc.asm ipc |
@pause |
/programs/network/ipc/trunk/ipc.asm |
---|
0,0 → 1,424 |
; |
; Example for Inter Process Communication |
; |
; 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 0x60000 ; memory for app |
dd 0x60000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Icon |
START: ; start of execution |
mov eax,60 ; IPC |
mov ebx,1 ; define receive area |
mov ecx,received_messages ; pointer to start |
mov edx,1000 ; size of area |
int 0x40 |
mov eax,40 ; WANTED EVENTS |
mov ebx,01000111b ; IPC 7 + defaults |
int 0x40 |
mov [received_messages+8],dword 0*256+0 |
mov [received_messages+12],dword 0 |
call draw_window ; at first, draw the window |
still: |
mov eax,23 ; wait here for event |
mov ebx,50 |
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,7 ; IPC ? |
jne no_ipc |
call display_ipc_messages |
jmp still |
no_ipc: |
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 ? |
jne noclose |
mov eax,-1 ; close this program |
int 0x40 |
noclose: |
cmp ah,2 |
jne no_read |
call read_string |
movzx eax,byte [message] |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [message+1] |
add eax,ebx |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [message+2] |
add eax,ebx |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [message+3] |
add eax,ebx |
sub eax,48 |
mov [PID],eax |
mov eax,60 ; IPC |
mov ebx,2 ; send message |
mov ecx,[PID] |
mov edx,message+4 |
mov esi,20;[message_size] |
int 0x40 |
jmp still |
no_read: |
cmp ah,3 |
jne no_messages_pop ; pop the first out |
call ipc_message_pop |
jmp still |
no_messages_pop: |
jmp still |
ipc_message_pop: |
pusha |
cmp [received_messages+4],dword 8 |
je already_empty |
mov [received_messages],byte 1 ; lock the area |
push dword [received_messages+4] |
mov ecx,[received_messages+12] |
sub [received_messages+4],ecx |
sub [received_messages+4],dword 8 |
mov edi,received_messages+8 |
mov esi,edi |
add esi,ecx |
add esi,8 |
pop ecx |
cld |
rep movsb |
call display_ipc_messages |
mov [received_messages],byte 0 ; free the area |
already_empty: |
popa |
ret |
display_ipc_messages: |
pusha |
mov eax,13 |
mov ebx,25*65536+245 |
mov ecx,105*65536+90 |
mov edx,0xdddddd |
int 0x40 |
cmp [received_messages+4],dword 8 ; empty list |
je ipma1 |
mov ebx,25*65536+105 ; draw info text with function 4 |
mov ecx,0x224466 |
mov edx,received_messages+8 |
mov esi,40 |
mov [counter],0 |
newline2: |
pusha |
mov ecx,[edx] |
and ecx,0xfff |
mov edx,ebx |
mov eax,47 |
mov ebx,4*65536 |
mov esi,0xff0000 |
int 0x40 |
popa |
pusha |
mov esi,20 |
add edx,8 |
add ebx,30*65536 |
mov eax,4 |
int 0x40 |
popa |
add ebx,10 |
mov edi,[edx+4] |
add edi,8 |
and edi,0xfff |
add edx,edi |
mov edi,[received_messages+4] |
add edi,received_messages |
cmp edx,edi |
jge ipma1 |
inc [counter] |
cmp [counter],8 |
jbe newline2 |
ipma1: |
popa |
ret |
counter dd 0x0 |
; ********************************************* |
; ******* 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+290 ; [x start] *65536 + [x size] |
mov ecx,100*65536+220 ; [y start] *65536 + [y size] |
mov edx,0x03ffffff ; 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,0x10ffffff ; color of text RRGGBB |
mov edx,labelt ; pointer to text beginning |
mov esi,labellen-labelt ; text length |
int 0x40 |
mov eax,9 |
mov ebx,process_info |
mov ecx,-1 |
int 0x40 |
mov eax,47 |
mov ebx,4*65536 |
mov ecx,[process_info+30] |
mov edx,180*65536+35 |
mov esi,0x000000 |
int 0x40 |
mov eax,8 ; MESSAGE |
mov ebx,25*65536+87 |
mov ecx,50*65536+16 |
mov edx,2 |
mov esi,0x5588dd |
int 0x40 |
mov eax,8 ; POP |
mov ebx,216*65536+53 |
mov ecx,80*65536+16 |
mov edx,3 |
mov esi,0x5588dd |
int 0x40 |
mov ebx,25*65536+35 ; draw info text with function 4 |
mov ecx,0x224466 |
mov edx,text |
mov esi,40 |
newline: |
mov eax,4 |
int 0x40 |
add ebx,10 |
add edx,40 |
cmp [edx],byte 'x' |
jne newline |
call display_ipc_messages |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
ret |
read_string: |
pusha |
mov [addr],dword message |
mov [ya],55 |
mov [xa],120 |
mov ecx,20 |
mov edi,[addr] |
mov al,' ' |
cld |
rep stosb |
call print_text |
mov edi,[addr] |
f11: |
mov eax,10 |
int 0x40 |
cmp eax,2 |
jz fbu |
exit_readkey: |
popa |
ret |
fbu: |
mov eax,2 |
int 0x40 ; get key |
shr eax,8 |
cmp eax,13 |
je exit_readkey |
cmp eax,8 |
jnz nobs |
cmp edi,[addr] |
jz f11 |
dec edi |
mov [edi],byte ' ' |
call print_text |
jmp f11 |
nobs: |
cmp eax,31 |
jbe f11 |
cmp eax,95 |
jb keyok |
sub eax,32 |
keyok: |
mov [edi],al |
call print_text |
inc edi |
mov esi,[addr] |
add esi,20 |
cmp esi,edi |
jnz f11 |
popa |
ret |
print_text: |
mov eax,13 |
mov ebx,[xa] |
shl ebx,16 |
add ebx,25*6 |
mov ecx,[ya] |
shl ecx,16 |
mov cx,8 |
mov edx,0xffffff |
int 0x40 |
mov eax,4 |
mov ebx,[xa] |
shl ebx,16 |
add ebx,[ya] |
mov ecx,0x000000 |
mov edx,[addr] |
mov esi,25 |
int 0x40 |
ret |
; DATA AREA |
ya dd 0x0 |
xa dd 0x0 |
addr dd 0x0 |
text: |
db 'PROCESS ID FOR THIS APP : ' |
db ' ' |
db ' PID:MESSAGE 0130 EXAMPLE MESSAGE ' |
db ' ' |
db ' ' |
db 'RECEIVED: POP ' |
db 'x' ; <- END MARKER, DONT DELETE |
labelt: |
db 'IPC - START AT LEAST 2' |
labellen: |
I_END: |
PID: dd 0x0 |
message_size: dd 20 |
received_messages: |
db 0 ; lock byte |
db 0,0,0 ; reserved |
dd 8 ; pointer to free msg position from received_messages |
; Sender PID |
; Msg length |
; Msg data |
rb 0x1000 |
message: times 70 db ? |
process_info: times 256 dd ? |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/ipc/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 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/local/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm local.asm local |
@pause |
/programs/network/local/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm local.asm local |
@pause |
/programs/network/local/trunk/local.asm |
---|
0,0 → 1,522 |
; |
; Remote processing example (local node) |
; |
; 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 0x100000 ; required amount of memory |
dd 0x00000000 ; reserved=no extended header |
include 'lang.inc' |
include 'macros.inc' |
START: ; start of execution |
mov eax,53 ; open socket |
mov ebx,0 |
mov ecx,0x2000 ; local port |
mov edx,0x3000 ; remote port |
mov esi,dword [host_ip] ; node IP |
int 0x40 |
mov [socketNum], eax |
call draw_window ; at first, draw the window |
still: |
mov eax,23 ; wait here for event |
mov ebx,1 |
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 |
mov eax, 53 ; get data |
mov ebx, 2 |
mov ecx, [socketNum] |
int 0x40 |
cmp eax, 0 |
jne read |
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 ; button id=1 ? |
jnz noclose |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
int 0x40 |
mov eax,-1 |
int 0x40 |
noclose: |
cmp ah,2 ; SEND CODE ? |
je send_xcode |
cmp ah,3 ; LEFT COORDINATES ? |
jne no_left |
mov [picture_position],0 |
mov dword [send_data+15],dword STARTX |
mov dword [send_data+19],dword 4 |
mov esi,send_data |
mov edi,I_END |
mov ecx,23 |
cld |
rep movsb |
mov [I_END+23],dword -20 |
mov eax,53 |
mov ebx,4 |
mov ecx,[socketNum] |
mov edx,23 + 4 |
mov esi,I_END |
int 0x40 |
jmp still |
no_left: |
cmp ah,4 ; RIGHT COORDINATES ? |
jne no_right |
mov [picture_position],128 |
mov dword [send_data+15],dword STARTX |
mov dword [send_data+19],dword 4 |
mov esi,send_data |
mov edi,I_END |
mov ecx,23 |
cld |
rep movsb |
mov [I_END+23],dword -20 + 128 |
mov eax,53 |
mov ebx,4 |
mov ecx,[socketNum] |
mov edx,23 + 4 |
mov esi,I_END |
int 0x40 |
jmp still |
no_right: |
cmp ah,5 ; SEND EXECUTE ? |
je send_execute |
jmp still |
xx dd 0 |
yy dd 0 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; SEND CODE TO REMOTE ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
send_xcode: |
mov dword [send_data+15],dword 0x80000 |
mov dword [send_data+19],dword remote_code_end - remote_code_start |
mov esi,send_data ; header |
mov edi,I_END |
mov ecx,23 |
cld |
rep movsb |
mov esi,remote_code ; remote_code_start ; data |
mov edi,I_END+23 |
mov ecx,remote_code_end - remote_code_start |
cld |
rep movsb |
mov eax,53 ; SEND CODE TO REMOTE |
mov ebx,4 |
mov ecx,[socketNum] |
mov edx,23 + remote_code_end - remote_code_start |
mov esi,I_END |
int 0x40 |
jmp still |
send_execute: |
mov dword [execute+15],dword draw_fractal |
mov eax,53 ; START EXECUTE AT REMOTE |
mov ebx,4 |
mov ecx,[socketNum] |
mov edx,19 |
mov esi,execute |
int 0x40 |
mov edi,3 |
jmp still |
;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; READ ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;; |
read: |
cfr007: |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte |
shl edx,8 |
mov dl,bl |
dec edi |
jnz cok |
mov edi,3 |
and edx,0xffffff |
mov eax,1 |
mov ebx,[xx] |
mov ecx,[yy] |
add ebx,15 |
add ecx,35 |
add ebx,[picture_position] |
int 0x40 |
inc [xx] |
cmp [xx],dword 128 |
jb cok |
mov [xx],0 |
inc [yy] |
cmp [yy],dword 128 |
jb cok |
mov [yy],0 |
cok: |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
int 0x40 ; any more data? |
cmp eax, 0 |
jne cfr007 ; yes, so get it |
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+286 ; [x start] *65536 + [x size] |
mov ecx,60*65536+330 ; [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 ; SEND CODE |
mov ebx,60*65536+160 |
mov ecx,181*65536+13 |
mov edx,2 |
mov esi,0x667788 |
int 0x40 |
mov eax,8 ; LEFT |
mov ebx,60*65536+75 |
mov ecx,197*65536+13 |
mov edx,3 |
mov esi,0x667788 |
int 0x40 |
mov eax,8 ; RIGHT |
mov ebx,148*65536+72 |
mov ecx,197*65536+13 |
mov edx,4 |
mov esi,0x667788 |
int 0x40 |
mov eax,8 ; SEND EXECUTE |
mov ebx,60*65536+160 |
mov ecx,213*65536+13 |
mov edx,5 |
mov esi,0x667788 |
int 0x40 |
cld |
mov ebx,25*65536+185 ; draw info text with function 4 |
mov ecx,0x000000 |
mov edx,text |
mov esi,40 |
newline: |
mov eax,4 |
int 0x40 |
add ebx,16 |
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 ' 1) SEND CODE ' |
db ' 2) LEFT RIGHT ' |
db " 3) SEND 'EXECUTE' " |
db ' ' |
db ' LOCAL : 192.168.1.26 ' |
db ' REMOTE : 192.168.1.22 ' |
db ' REMOTE CODE AT THE END OF THIS FILE ' |
db 'x <- END MARKER, DONT DELETE ' |
labeltext: db 'CLUSTER LOCAL' ; |
lte: |
socketNum dd 0x0 |
host_ip db 192,168,1,22 |
picture_position dd 0x0 |
send_data db 'MenuetRemote00' ; 00 header ; -> remote port 0x3000 |
db 1 ; 14 send |
dd 0x0 ; 15 position |
dd 0x0 ; 19 size |
; 23 |
execute db 'MenuetRemote00' ; 00 header ; -> remote port 0x3000 |
db 2 ; 14 execute |
dd 0x0 ; 15 position |
; 19 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; REMOTE CODE ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
remote_code: |
org 0x80000 |
remote_code_start: |
PIXWIDTH equ 129 |
PIXHEIGHT equ 129 |
ZOOMLIMIT equ 13 |
DELTA equ 200 |
THRESHOLD equ 7 |
STARTSCALE equ 6 |
CHAR_COLOR equ 0fh |
STARTX dd -20 |
STARTY dd 10 |
scaleaddy dd 60 |
scaleaddx dd 100 |
draw_fractal: |
pusha |
movzx ebp,word [STARTX] |
movzx edi,word [STARTY] |
mov cx, PIXHEIGHT ; height of screen in pixels |
sub di,cx ; adjust our Y offset |
@@CalcRow: |
push cx |
mov cx, PIXWIDTH -1 ; width of screen in pixels |
sub bp,cx ; |
@@CalcPixel: |
push cx ; save the column counter on stack |
xor cx, cx ; clear out color loop counter |
xor bx, bx ; zero i coefficient |
xor dx, dx ; zero j coefficient |
@@CycleColors: |
push dx ; save j value for later |
mov ax, bx ; ax = i |
sub ax, dx ; ax = i - j |
add dx, bx ; dx = i + j |
stc ; one additional shift, please |
call Shifty ; ax = ((i+j)*(i-j)) shifted right |
pop dx ; retrieve our saved value for j |
add ax,bp ; account for base offset... |
cmp ah,THRESHOLD ; Q: is i > THRESHOLD * 256? |
xchg bx,ax ; now swap new i with old i |
jg @@draw ; Y: draw this pixel |
clc ; no additional shifts here, please |
call Shifty ; now dx:ax = old i * j |
xchg dx,ax ; |
add dx,di ; account for base offset... |
inc cl ; increment color |
jnz @@CycleColors ; keep going until we're done |
@@draw: |
xchg ax, cx ; mov color into al |
pop cx ; retrieve our column counter |
pop dx ; fetch row (column already in cx) |
push dx ; must leave a copy on the stack |
xor bx,bx ; write to video page zero |
call store_pixel |
inc bp |
loop @@CalcPixel |
inc di |
pop cx |
loop @@CalcRow |
call return_data |
popa |
ret |
Shifty: |
push cx |
db 0b1h |
scale db STARTSCALE |
adc cl,0 |
imul dx |
xchg ax,dx |
shl eax,16 |
xchg ax,dx |
shr eax,cl |
pop cx |
ret |
pixel_pos: dd data_area |
store_pixel: |
pusha |
mov ebx,[pixel_pos] |
shl eax,3 |
and eax,0xff |
mov [ebx],eax |
add dword [pixel_pos],dword 3 |
popa |
ret |
return_data: |
mov ecx,128 * 128/16 |
mov esi,data_area |
sd: |
pusha |
mov eax,53 ; use the socket provided by host |
mov ebx,4 |
mov ecx,[0] |
mov edx,3*16 |
int 0x40 |
mov eax,5 |
mov ebx,1 |
int 0x40 |
popa |
add esi,3*16 |
loop sd |
ret |
data_area: |
remote_code_end: |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/local/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 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/md5/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm md5.asm md5 |
@pause |
/programs/network/md5/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm md5.asm md5 |
@pause |
/programs/network/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: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/netsendc/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm netsendc.asm netsendc |
@pause |
/programs/network/netsendc/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm netsendc.asm netsendc |
@pause |
/programs/network/netsendc/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 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/netsendc/trunk/netsendc.asm |
---|
0,0 → 1,198 |
; |
; NetSend(Client) |
; |
; ¢â®à: Hex |
; ©â: www.mestack.narod.ru |
; |
; ¯¨á ¨¥: |
; à®£à ¬¬ ¤«ï ®¡¬¥ á®®¡é¥¨ï¬¨ ¢ á¥â¨.«¨¥â᪠ï ç áâì. |
; |
; Compile with FASM for Menuet |
; ®¬¯¨«¨àã¥âáï FASM'®¬ ¤«ï ¥ãíâ |
; |
use32 |
org 0x0 |
db 'MENUET00' ; 8 byte id |
dd 38 ; required os |
dd START ; program start |
dd I_END ; program image size |
dd 0x100000 ; required amount of memory |
dd 0x00000000 ; reserved=no extended header |
include 'lang.inc' |
include 'macros.inc' |
START: ; start of execution |
mov eax,53 ; open socket |
mov ebx,0 |
mov ecx,0x4000 ; local port |
mov edx,0x5000 ; remote port |
mov esi,dword [remote_ip] ; node IP |
int 0x40 |
mov [socketNum], eax |
call draw_window ; at first, draw the window |
still: |
mov eax,23 ; wait here for event |
mov ebx,1 |
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: |
call draw_window |
jmp still |
key: |
mov eax,2 |
int 0x40 |
jmp still |
button: |
mov eax,17 |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jnz noclose |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
int 0x40 |
mov eax,-1 |
int 0x40 |
noclose: |
cmp ah,2 ; SEND CODE ? |
je send_xcode |
jmp still |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; SEND CODE TO REMOTE ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
send_xcode: |
mov esi,send_data ; header |
mov edi,I_END |
mov ecx,end_message-send_data |
cld |
rep movsb |
mov eax,53 ; SEND CODE TO REMOTE |
mov ebx,4 |
mov ecx,[socketNum] |
mov edx,end_message-send_data |
mov esi,I_END |
int 0x40 |
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+250 ; [x start] *65536 + [x size] |
mov ecx,60*65536+150 ; [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 ; SEND MESSAGE |
mov ebx,50*65536+145 |
mov ecx,47*65536+13 |
mov edx,2 |
mov esi,0x667788 |
int 0x40 |
cld |
mov ebx,25*65536+50 ; draw info text with function 4 |
mov ecx,0x000000 |
mov edx,text |
mov esi,40 |
newline: |
mov eax,4 |
int 0x40 |
add ebx,16 |
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 ' ®á« âì á®®¡é¥¨¥ ' |
db ' ' |
db ' ®ª «ìë© ¤à¥á : 192.168.0.1 ' |
db ' ¤ «ñë© ¤à¥á : 192.168.0.2 ' |
db '¥ªáâ ¨ ¤à¥á ¢ ª®æ¥ ¨á室¨ª ' |
db 'x <- END MARKER, DONT DELETE ' |
labeltext: db 'NetSend(Client)' ; |
lte: |
socketNum dd 0x0 |
remote_ip db 192,168,1,2 |
picture_position dd 0x0 |
send_data db 'ਢ¥â,íâ® â¥áâ!Hello,this is a test!' |
end_message: |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/netsends/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm netsends.asm netsends |
@pause |
/programs/network/netsends/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm netsends.asm netsends |
@pause |
/programs/network/netsends/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 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/netsends/trunk/netsends.asm |
---|
0,0 → 1,207 |
; |
; NetSend(Server) |
; |
; ¢â®à: Hex |
; ©â: www.mestack.narod.ru |
; |
; ¯¨á ¨¥: |
; à®£à ¬¬ ¤«ï ®¡¬¥ á®®¡é¥¨ï¬¨ ¢ á¥â¨.¥à¢¥à ï ç áâì. |
; |
; Compile with FASM for Menuet |
; ®¬¯¨«¨àã¥âáï FASM'®¬ ¤«ï ¥ãíâ |
; |
use32 |
org 0x0 |
db 'MENUET00' ; 8 byte id |
dd 38 ; required os |
dd START ; program start |
dd I_END ; program image size |
dd 0x100000 ; required amount of memory |
dd 0x00000000 ; reserved=no extended header |
include 'lang.inc' |
include 'macros.inc' |
remote_ip db 192,168,0,1 |
START: ; start of execution |
mov eax, 53 ; open receiver socket |
mov ebx, 0 |
mov ecx, 0x5000 ; local port |
mov edx, 0xffff ; remote port |
mov esi, dword [remote_ip] ; remote IP |
int 0x40 |
mov [socketNum],eax |
mov [0],eax ; save for remote code |
call draw_window ; at first, draw the window |
still: |
mov eax,23 ; wait here for event |
mov ebx,1 |
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 |
mov eax,53 ; data from cluster terminal ? |
mov ebx,2 |
mov ecx,[socketNum] |
int 0x40 |
cmp eax,0 |
jne data_arrived |
jmp still |
red: |
call draw_window |
jmp still |
key: |
mov eax,2 |
int 0x40 |
jmp still |
button: |
mov eax,53 |
mov ebx,1 |
mov ecx,[socketNum] |
int 0x40 |
mov eax,-1 |
int 0x40 |
data_arrived: |
mov eax,5 ; wait a second for everything to arrive |
mov ebx,10 |
int 0x40 |
mov edi,I_END |
get_data: |
mov eax,53 |
mov ebx,3 |
mov ecx,[socketNum] |
int 0x40 |
mov [edi],bl |
inc edi |
mov eax,53 |
mov ebx,2 |
mov ecx,[socketNum] |
int 0x40 |
cmp eax,0 |
jne get_data |
mov eax,4 |
mov ebx,10*65536+60 |
add ebx,[y] |
mov ecx,0x000000 |
mov edx,I_END |
mov esi,100 |
int 0x40 |
add [y],10 |
jmp still |
y dd 0x10 |
; ********************************************* |
; ******* 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+330 ; [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 |
mov eax,8 |
mov ebx,(286-19)*65536+12 |
mov ecx,4*65536+12 |
mov edx,1 |
mov esi,0xaabbcc |
; 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 |
; Re-draw the screen text |
cld |
mov ebx,10*65536+30 ; draw info text with function 4 |
mov ecx,0x000000 |
mov edx,text |
mov esi,40 |
newline: |
mov eax,4 |
int 0x40 |
add ebx,16 |
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 ' ë© ¤à¥á : 192.168.0.2 ' |
db 'à®á«ã訢 ¥¬ë© ¯®àâ : 0x5000 ' |
db 'à¨á« ë¥ á®®¡é¥¨ï: ' |
db 'x <- END MARKER, DONT DELETE ' |
labeltext: db 'NetSend(Server)' |
lte: |
socketNum dd 0x0 |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/nntpc/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm nntpc.asm nntpc |
@pause |
/programs/network/nntpc/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm nntpc.asm nntpc |
@pause |
/programs/network/nntpc/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 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/nntpc/trunk/nntpc.asm |
---|
0,0 → 1,933 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; |
;; NNTP CLIENT v 0.1 |
;; |
;; (C) Ville Turjanmaa |
;; |
version equ '0.1' |
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 0x80000 ; memory for app |
dd 0x80000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Icon |
connect_state db 0,0,'Disconnected' |
db 1,3,'Trying.. ' |
db 4,4,'Connected ' |
db 5,9,'Closing.. ' |
prev_state dd -1 |
space dd 0x0 |
text_start dd 0x0 |
text_current dd 0x0 |
status dd 0x0 |
server_ip db 192,168,0,96 |
socket dd 0x0 |
xpos dd 0x0 |
ypos dd 0x0 |
;; |
group db 'GROUP alt.test',13,10 |
db ' ' |
grouplen dd 16 |
stat db 'STAT ' |
statlen dd 0x0 |
article db 'ARTICLE',13,10 |
articlelen: |
;; |
quit db 'QUIT',13,10 |
quitlen: |
xwait dd 0x0 |
ywait dd 0x0 |
article_n dd 0x0 |
article_l dd 0x0 |
article_start dd 0x0 |
article_last dd 0x0 |
article_all dd 0x0 |
article_fetch dd 0x0 |
xpost dd 0x0 |
edisave dd 0x0 |
connection_status: |
pusha |
mov eax,53 |
mov ebx,6 |
mov ecx,[socket] |
int 0x40 |
cmp eax,[prev_state] |
je no_cos |
mov [prev_state],eax |
mov eax,13 |
mov ebx,435*65536+12*6 |
mov ecx,42*65536+10 |
mov edx,0xffffff |
int 0x40 |
mov ecx,-14 |
mov eax,[prev_state] |
next_test: |
add ecx,14 |
cmp ecx,14*4 |
je no_cos |
cmp al,[connect_state+ecx+0] |
jb next_test |
cmp al,[connect_state+ecx+1] |
jg next_test |
mov edx,ecx |
add edx,2 |
add edx,connect_state |
mov eax,4 |
mov ebx,435*65536+42 |
mov ecx,0x000000 |
mov esi,12 |
int 0x40 |
no_cos: |
popa |
ret |
text_input: |
pusha |
mov ecx,25 |
mov eax,32 |
cld |
rep stosb |
popa |
mov [edisave],edi |
ti0: |
mov [edi],byte ' ' |
call draw_entries |
mov eax,10 |
int 0x40 |
cmp eax,2 |
jne no_more_text |
mov eax,2 |
int 0x40 |
cmp ah,8 |
jne no_bg |
cmp edi,[edisave] |
je ti0 |
dec edi |
jmp ti0 |
no_bg: |
cmp ah,13 |
je no_more_text |
mov [edi],ah |
inc edi |
call draw_entries |
jmp ti0 |
no_more_text: |
mov [xpost],edi |
ret |
convert_text_to_ip: |
pusha |
mov edi,server_ip |
mov esi,text+10 |
mov eax,0 |
mov edx,[xpost] |
newsip: |
cmp [esi],byte '.' |
je sipn |
cmp esi,edx |
jge sipn |
movzx ebx,byte [esi] |
inc esi |
imul eax,10 |
sub ebx,48 |
add eax,ebx |
jmp newsip |
sipn: |
mov [edi],al |
xor eax,eax |
inc esi |
cmp esi,text+50 |
jg sipnn |
inc edi |
cmp edi,server_ip+3 |
jbe newsip |
sipnn: |
popa |
ret |
send_group: |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov edx,[grouplen] |
mov esi,group |
int 0x40 |
mov [status],3 |
call clear_text |
call save_coordinates |
ret |
convert_number_to_text: |
pusha |
mov eax,[esi] |
mov ecx,0 |
newch: |
inc ecx |
xor edx,edx |
mov ebx,10 |
div ebx |
cmp eax,0 |
jne newch |
add edi,ecx |
dec edi |
mov [article_l],ecx |
mov eax,[esi] |
newdiv: |
xor edx,edx |
mov ebx,10 |
div ebx |
add edx,48 |
mov [edi],dl |
dec edi |
loop newdiv |
popa |
ret |
convert_text_to_number: |
pusha |
mov edx,0 |
newdigit: |
movzx eax,byte [esi] |
cmp eax,'0' |
jb cend |
cmp eax,'9' |
jg cend |
imul edx,10 |
add edx,eax |
sub edx,48 |
inc esi |
jmp newdigit |
cend: |
mov [edi],edx |
popa |
ret |
clear_text: |
mov [text_start],0 |
mov [xpos],0 |
mov [ypos],0 |
mov [xwait],0 |
mov [ywait],0 |
mov edi,nntp_text |
mov ecx,0x50000 |
mov eax,32 |
cld |
rep stosb |
ret |
state_machine_write: |
cmp [status],2 |
jne no_22 |
call send_group |
ret |
no_22: |
cmp [status],4 |
jne no_4 |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov edx,[statlen] ; -stat |
mov esi,stat |
int 0x40 |
mov [status],5 |
call save_coordinates |
ret |
no_4: |
cmp [status],6 |
jne no_6 |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov edx,articlelen-article |
mov esi,article |
int 0x40 |
mov [status],7 |
call save_coordinates |
ret |
no_6: |
ret |
save_coordinates: |
mov eax,[xpos] |
mov ebx,[ypos] |
mov [xwait],eax |
mov [ywait],ebx |
ret |
state_machine_read: |
cmp [status],1 |
jne no_1 |
mov eax,'200 ' |
call wait_for_string |
ret |
no_1: |
cmp [status],3 ;; responce to group |
jne no_3 |
mov eax,'211 ' |
call wait_for_string |
ret |
no_3: |
cmp [status],5 ;; responce to stat |
jne no_5 |
mov eax,'223 ' |
call wait_for_string |
ret |
no_5: |
;; after 'article' request - no wait |
cmp [status],9 |
jne no_9 |
mov eax,'222 ' |
call wait_for_string |
ret |
no_9: |
ret |
wait_for_string: |
mov ecx,[ywait] |
imul ecx,80 |
add ecx,[xwait] |
mov ecx,[nntp_text+ecx] |
cmp eax,ecx |
jne no_match |
cmp [status],3 |
jne no_stat_ret |
mov esi,[ywait] |
imul esi,80 |
add esi,[xwait] |
new32s: |
inc esi |
movzx eax,byte [esi+nntp_text] |
cmp eax,47 |
jge new32s |
new32s2: |
inc esi |
movzx eax,byte [esi+nntp_text] |
cmp eax,47 |
jge new32s2 |
inc esi |
add esi,nntp_text |
; mov [esi-1],byte '.' |
mov edi,article_n |
call convert_text_to_number |
mov eax,[article_n] |
mov [article_start],eax |
new32s3: |
inc esi |
movzx eax,byte [esi] |
cmp eax,47 |
jge new32s3 |
inc esi |
mov edi,article_last |
call convert_text_to_number |
mov eax,[text_current] |
add [article_n],eax |
mov esi,article_n |
mov edi,nntp_text+71 |
call convert_number_to_text |
mov esi,article_n |
mov edi,stat+5 |
call convert_number_to_text |
mov eax,[article_l] |
mov [stat+5+eax],byte 13 |
mov [stat+6+eax],byte 10 |
add eax,5+2 |
mov [statlen],eax |
pusha |
mov edi,text+10+66*2 |
mov ecx,25 |
mov eax,32 |
cld |
rep stosb |
mov esi,text_current |
mov edi,text+10+66*2 |
call convert_number_to_text |
mov eax,32 |
mov ecx,20 |
mov edi,text+10+66*3 |
cld |
rep stosb |
mov eax,[article_last] |
sub eax,[article_start] |
mov [article_all],eax |
mov esi,article_all |
mov edi,text+10+66*3 |
call convert_number_to_text |
call draw_entries |
popa |
call draw_text |
no_stat_ret: |
inc [status] |
mov eax,5 |
mov ebx,10 |
int 0x40 |
call check_for_incoming_data |
no_match: |
ret |
START: ; start of execution |
mov eax,40 |
mov ebx,10000111b |
int 0x40 |
call clear_text |
call draw_window |
still: |
call state_machine_write |
call state_machine_read |
mov eax,23 ; wait here for event |
mov ebx,5 |
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 |
call check_for_incoming_data |
call connection_status |
jmp still |
red: ; redraw |
call draw_window |
jmp still |
key: ; key |
mov eax,2 ; just read it and ignore |
int 0x40 |
cmp ah,' ' |
jne no_space |
mov eax,[space] |
dec eax |
add [text_start],eax |
call draw_text |
jmp still |
no_space: |
cmp ah,177 |
jne no_plus |
inc [text_start] |
call draw_text |
jmp still |
no_plus: |
cmp ah,178 |
jne no_minus |
cmp [text_start],0 |
je no_minus |
dec [text_start] |
call draw_text |
jmp still |
no_minus: |
cmp ah,179 |
jne no_next |
inc [text_current] |
call send_group |
jmp still |
no_next: |
cmp ah,176 |
jne no_prev |
cmp [text_current],0 |
je still |
dec [text_current] |
call send_group |
jmp still |
no_prev: |
jmp still |
button: ; button |
mov eax,17 ; get id |
int 0x40 |
shr eax,8 |
cmp eax,11 |
jne no_11 |
mov edi,text+10 |
call text_input |
call convert_text_to_ip |
jmp still |
no_11: |
cmp eax,12 |
jne no_12 |
mov edi,text+66+10 |
call text_input |
mov esi,text+66+10 |
mov edi,group+6 |
mov ecx,[xpost] |
sub ecx,text+66+10 |
mov eax,ecx |
cld |
rep movsb |
mov [group+6+eax],byte 13 |
mov [group+7+eax],byte 10 |
add eax,6+2 |
mov [grouplen],eax |
mov [text_current],0 |
jmp still |
no_12: |
cmp eax,13 |
jne no_13 |
mov edi,text+10+66*2 |
call text_input |
mov esi,text+10+66*2 |
mov edi,text_current |
call convert_text_to_number |
call send_group |
jmp still |
no_13: |
cmp eax,14 |
jne no_start |
call clear_text |
mov eax,3 |
int 0x40 |
mov ecx,eax |
mov eax,53 |
mov ebx,5 |
mov edx,119 |
mov esi,dword [server_ip] |
mov edi,1 |
int 0x40 |
mov [socket],eax |
mov [status],1 |
jmp still |
no_start: |
cmp eax,15 |
jne no_end |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov edx,quitlen-quit |
mov esi,quit |
int 0x40 |
mov eax,5 |
mov ebx,10 |
int 0x40 |
call check_for_incoming_data |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
int 0x40 |
mov eax,5 |
mov ebx,5 |
int 0x40 |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
int 0x40 |
mov [status],0 |
jmp still |
no_end: |
cmp eax,1 ; button id=1 ? |
jne noclose |
mov eax,-1 ; close this program |
int 0x40 |
noclose: |
jmp still |
check_for_incoming_data: |
cmp [status],0 |
jne go_on |
ret |
go_on: |
mov eax,53 |
mov ebx,2 |
mov ecx,[socket] |
int 0x40 |
cmp eax,0 |
je ch_ret |
mov eax,53 |
mov ebx,3 |
mov ecx,[socket] |
int 0x40 |
and ebx,0xff |
cmp ebx,13 |
jb no_print |
cmp bl,13 |
jne char |
mov [xpos],0 |
inc [ypos] |
jmp no_print |
char: |
cmp ebx,128 |
jbe char_ok |
mov ebx,'?' |
char_ok: |
mov ecx,[ypos] |
imul ecx,80 |
add ecx,[xpos] |
mov [nntp_text+ecx],bl |
cmp [xpos],78 |
jg noxinc |
inc [xpos] |
noxinc: |
no_print: |
mov eax,53 |
mov ebx,2 |
mov ecx,[socket] |
int 0x40 |
cmp eax,0 |
jne check_for_incoming_data |
call draw_text |
ch_ret: |
ret |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
pusha |
mov [prev_state],-1 |
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+520 ; [x start] *65536 + [x size] |
mov ecx,5*65536+470 ; [y start] *65536 + [y size] |
mov edx,0x03ffffff ; color of work area RRGGBB,8->color gl |
mov esi,0x805080d0 ; color of grab bar RRGGBB,8->color gl |
mov edi,0x005080d0 ; color of frames RRGGBB |
int 0x40 |
mov eax,38 |
mov ebx,5*65536+515 |
mov ecx,101*65536+101 |
mov edx,0x99bbff |
int 0x40 |
mov eax,38 |
mov ebx,5*65536+515 |
mov ecx,102*65536+102 |
mov edx,0x3366aa |
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,0x10ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
mov edx,labelt ; pointer to text beginning |
mov esi,labellen-labelt ; text length |
int 0x40 |
mov eax,8 |
mov ebx,238*65536+8 |
mov ecx,30*65536+8 |
mov edx,11 |
mov esi,0x88aadd |
int 0x40 |
mov eax,8 |
mov ebx,238*65536+8 |
mov ecx,41*65536+8 |
mov edx,12 |
int 0x40 |
mov eax,8 |
mov ebx,238*65536+8 |
mov ecx,52*65536+8 |
mov edx,13 |
int 0x40 |
mov eax,8 |
mov ebx,265*65536+75 |
mov ecx,39*65536+13 |
mov edx,14 |
int 0x40 |
mov eax,8 |
mov ebx,351*65536+75 |
mov ecx,39*65536+13 |
mov edx,15 |
int 0x40 |
call draw_entries |
call draw_text |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
popa |
ret |
draw_entries: |
pusha |
mov eax,13 |
mov ebx,30*65536+200 |
mov ecx,30*65536+44 |
mov edx,0xffffff |
int 0x40 |
mov ebx,30*65536+31 ; draw info text with function 4 |
mov ecx,0x000000 |
mov edx,text |
mov esi,66 |
mov edi,6 |
newline2: |
mov eax,4 |
int 0x40 |
add ebx,11 |
add edx,66 |
dec edi |
jnz newline2 |
popa |
ret |
draw_text: |
pusha |
mov eax,9 |
mov ebx,0x70000 |
mov ecx,-1 |
int 0x40 |
mov eax,[0x70000+46] |
cmp eax,150 |
jbe dtret |
sub eax,111 |
mov ebx,10 |
xor edx,edx |
div ebx |
mov edi,eax |
dec edi |
mov [space],edi |
mov ebx,20*65536+111 ; draw info text with function 4 |
mov ecx,0x000000 |
mov edx,[text_start] |
imul edx,80 |
add edx,nntp_text |
mov esi,80 |
newline: |
pusha |
mov ecx,ebx |
shl ecx,16 |
mov eax,13 |
mov ebx,20*65536+80*6 |
mov cx,10 |
mov edx,0xffffff |
int 0x40 |
popa |
mov eax,4 |
int 0x40 |
add ebx,10 |
add edx,80 |
dec edi |
jnz newline |
dtret: |
popa |
ret |
; DATA AREA |
text: |
db 'NNTP IP : 192.168.0.96 < ' |
db 'Group : alt.test < Connect Disconnect ' |
db 'Article : 0 < ' |
db 'Art.max : ? ' |
db ' ' |
db 'Arrow left/rigth: fetch prev/next - Arrow up/down & space: scroll ' |
textl: |
labelt: |
db 'NNTP client v',version |
labellen: |
nntp_text: |
db 'a' |
I_END: ;;; |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/popc/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm popc.asm popc |
@pause |
/programs/network/popc/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm popc.asm popc |
@pause |
/programs/network/popc/trunk/popc.asm |
---|
0,0 → 1,1029 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; POP CLIENT for MenuetOS ;; |
;; - Modified from IRC client ;; |
;; ;; |
;; License: GPL / See file COPYING for details ;; |
;; Copyright 2002 (c) Ville Turjanmaa ;; |
;; ;; |
;; Compile with FASM for Menuet ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
include 'lang.inc' |
version equ '0.1' |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; required os |
dd START ; program start |
dd I_END ; program image size |
dd 0x200000 ; required amount of memory |
dd 0xffff0 |
dd 0,0 |
START: ; start of execution |
mov [file_start],0x100000 |
mov eax,58 |
mov ebx,filel |
int 0x40 |
cmp eax,0 |
jne notfound |
add [file_start],ebx |
notfound: |
mov edi,I_END |
mov ecx,60*120 |
mov eax,32 |
cld |
rep stosb |
mov eax,[rxs] |
imul eax,11 |
mov [pos],eax |
mov ebp,0 |
mov edx,I_END |
call draw_window ; at first, draw the window |
still: |
mov eax,5 |
mov ebx,1 |
int 0x40 |
mov eax,11 ; wait here for event |
int 0x40 |
cmp eax,1 ; redraw |
je redraw |
cmp eax,2 ; key |
je key |
cmp eax,3 ; button |
je button |
cmp [I_END+120*60],byte 1 |
jne no_main_update |
mov [I_END+120*60],byte 0 |
mov edx,I_END |
call draw_server_data |
no_main_update: |
cmp [server_active],0 |
je noread |
call read_incoming_data |
noread: |
call print_status |
cmp [status],4 |
je send_request |
jmp still |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; |
;; Save the fetched mails |
;; |
save_file: |
pusha |
mov edi,[file_start] |
mov eax,[file_start] |
sub eax,0x100000 |
mov [files+8],eax |
mov eax,58 |
mov ebx,files |
int 0x40 |
popa |
ret |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; |
;; Send user id/passwd/mailrq |
;; |
send_request: |
inc [mcounter] |
cmp [mcounter],1000 |
jbe no_send |
mov eax,[ccounter] |
imul eax,32 |
add eax,getmail |
mov esi,eax |
inc [ccounter] |
mov edx,32 |
cmp [ccounter],1 |
jne no1 |
mov edx,5+2 |
add edx,[l2] |
no1: |
cmp [ccounter],2 |
jne no2 |
mov edx,5+2 |
add edx,[l3] |
no2: |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
int 0x40 |
mov [mcounter],0 |
cmp [esi],dword 'quit' |
je close_fetch |
no_send: |
jmp still |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; |
;; Close connection to server |
;; |
close_fetch: |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov edx,14 |
mov esi,quitc |
int 0x40 |
mov [mcounter],0 |
mov eax,5 |
mov ebx,150 |
int 0x40 |
call read_incoming_data |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
int 0x40 |
mov eax,5 |
mov ebx,2 |
int 0x40 |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
int 0x40 |
mov [server_active],0 |
jmp still |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; |
;; User input processing |
;; |
redraw: ; redraw |
call draw_window |
jmp still |
key: |
mov eax,2 |
int 0x40 |
jmp still |
button: ; button |
mov eax,17 ; get id |
int 0x40 |
cmp ah,60 |
jne no_open |
mov eax,19 |
mov ebx,tp |
mov ecx,pr |
int 0x40 |
jmp still |
no_open: |
cmp ah,1 ; close program |
jne noclose |
mov eax,-1 |
int 0x40 |
noclose: |
cmp ah,51 |
je read_string |
cmp ah,52 |
je read_string |
cmp ah,53 |
je read_string |
call socket_commands |
jmp still |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; |
;; Socket open & close |
;; |
socket_commands: |
cmp ah,22 ; open socket |
jnz tst3 |
mov [server_active],1 |
mov [mcounter],900 |
mov [ccounter],0 |
mov eax,3 |
int 0x40 |
mov eax,3 |
int 0x40 |
mov ecx,eax |
and ecx,0xffff |
mov eax,53 |
mov ebx,5 |
mov edx,110 |
mov esi,dword [ip] |
mov edi,1 |
int 0x40 |
mov [socket], eax |
ret |
tst3: |
cmp ah,24 ; close socket |
jnz no_24 |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
int 0x40 |
mov [header_sent],0 |
mov [mail_rp],0 |
mov [server_active],0 |
ret |
no_24: |
ret |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; |
;; Display connection status |
;; |
old_status dd 0x0 |
print_status: |
pusha |
mov eax,53 |
mov ebx,6 |
mov ecx,[socket] |
int 0x40 |
mov [status],eax |
cmp eax,[old_status] |
je nopr |
mov [old_status],eax |
push eax |
mov eax,13 |
mov ebx,200*65536+30 |
mov ecx,160*65536+10 |
mov edx,0xffffff |
int 0x40 |
pop ecx |
cmp [server_active],1 |
jne nopr |
mov eax,47 |
mov ebx,3*65536 |
mov edx,200*65536+160 |
mov esi,0x000000 |
int 0x40 |
nopr: |
popa |
ret |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; |
;; Read data from server |
;; |
read_incoming_data: |
pusha |
read_new_byte: |
call read_incoming_byte |
cmp ecx,-1 |
je no_data_in_buffer |
mov eax,[file_start] |
mov [eax],bl |
inc [file_start] |
cmp bl,10 |
jne no_start_command |
mov [cmd],1 |
no_start_command: |
cmp bl,13 |
jne no_end_command |
mov eax,[cmd] |
mov [eax+command-2],byte 0 |
call save_file |
call analyze_data |
mov edi,command |
mov ecx,250 |
mov eax,0 |
cld |
rep stosb |
mov [cmd],0 |
no_end_command: |
mov eax,[cmd] |
cmp eax,250 |
jge still |
mov [eax+command-2],bl |
inc [cmd] |
jmp read_new_byte |
no_data_in_buffer: |
popa |
ret |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; |
;; Read user input for ip/user/passwd |
;; |
read_string: |
shr eax,8 |
sub eax,51 |
mov ebx,eax |
imul eax,12 |
add eax,181 |
mov [len],ebx |
shl [len],2 |
add [len],l1 |
imul ebx,50 |
add ebx,input1 |
mov [addr],ebx |
mov [ya],eax |
mov edi,[addr] |
mov eax,0 |
mov ecx,30 |
cld |
rep stosb |
call print_input_text |
mov edi,[addr] |
f11: |
mov eax,10 |
int 0x40 |
cmp eax,2 |
jne read_done |
mov eax,2 |
int 0x40 |
shr eax,8 |
cmp eax,13 |
je read_done |
cmp eax,8 |
jnz nobsl |
cmp edi,[addr] |
jz f11 |
sub edi,1 |
mov [edi],byte 32 |
call print_text |
jmp f11 |
nobsl: |
mov [edi],al |
call print_input_text |
add edi,1 |
mov esi,[addr] |
add esi,30 |
cmp esi,edi |
jnz f11 |
read_done: |
push edi |
mov ecx,40 |
mov eax,32 |
cld |
rep stosb |
call print_input_text |
pop edi |
sub edi,[addr] |
mov eax,[len] |
mov [eax],edi |
cmp [len],l1 |
jne noip |
mov esi,input1 |
mov edi,ip_text+15 |
mov ecx,16 |
cld |
rep movsb |
call ip_set |
noip: |
cmp [len],l2 |
jne nol2 |
mov esi,input2 |
mov edi,l2_text+15 |
mov ecx,22 |
cld |
rep movsb |
mov esi,input2 |
mov edi,getmail+5 |
mov ecx,[l2] |
cld |
rep movsb |
mov al,13 |
stosb |
mov al,10 |
stosb |
nol2: |
cmp [len],l3 |
jne nol3 |
mov esi,input3 |
mov edi,getmail+32+5 |
mov ecx,[l3] |
cld |
rep movsb |
mov al,13 |
stosb |
mov al,10 |
stosb |
nol3: |
call draw_window |
jmp still |
print_input_text: |
pusha |
mov eax,13 |
mov ebx,95*65536+23*6 |
mov ecx,[ya] |
shl ecx,16 |
mov cx,9 |
mov edx,0xffffff |
int 0x40 |
cmp [len],l3 |
je noprt |
mov eax,4 |
mov edx,[addr] |
mov ebx,95*65536 |
add ebx,[ya] |
mov ecx,0x000000 |
mov esi,23 |
int 0x40 |
noprt: |
popa |
ret |
ip_set: |
mov esi,input1-1 |
mov edi,ip |
xor eax,eax |
ip1: |
inc esi |
cmp [esi],byte '0' |
jb ip2 |
cmp [esi],byte '9' |
jg ip2 |
imul eax,10 |
movzx ebx,byte [esi] |
sub ebx,48 |
add eax,ebx |
jmp ip1 |
ip2: |
mov [edi],al |
xor eax,eax |
inc edi |
cmp edi,ip+3 |
jbe ip1 |
ret |
no_read_ip: |
ret |
analyze_data: |
pusha |
mov [text_start],I_END |
mov ecx,[rxs] |
imul ecx,11 |
mov [pos],ecx |
mov bl,13 |
call print_character |
mov bl,10 |
call print_character |
cmp [cmd],2 |
jbe nott |
mov ecx,[cmd] |
sub ecx,2 |
mov esi,command+0 |
newcmdc: |
mov bl,[esi] |
call print_character |
inc esi |
loop newcmdc |
nott: |
mov edx,I_END |
call draw_server_data |
cmd_len_ok: |
cmp [command],dword '-ERR' |
je close_fetch |
cmp [command],word '+O' |
jne nook |
mov [mcounter],990 |
nook: |
popa |
ret |
draw_data: |
push eax |
add eax,[text_start] |
mov [eax],bl |
pop eax |
ret |
print_text: |
pusha |
mov ecx,command-2 |
add ecx,[cmd] |
ptr2: |
mov bl,[eax] |
cmp bl,dl |
je ptr_ret |
cmp bl,0 |
je ptr_ret |
call print_character |
inc eax |
cmp eax,ecx |
jbe ptr2 |
ptr_ret: |
mov eax,[text_start] |
mov [eax+120*60],byte 1 |
popa |
ret |
print_character: |
pusha |
cmp bl,13 ; line beginning |
jne nobol |
mov ecx,[pos] |
add ecx,1 |
boll1: |
sub ecx,1 |
mov eax,ecx |
xor edx,edx |
mov ebx,[rxs] |
div ebx |
cmp edx,0 |
jne boll1 |
mov [pos],ecx |
jmp newdata |
nobol: |
cmp bl,10 ; line down |
jne nolf |
addx1: |
add [pos],dword 1 |
mov eax,[pos] |
xor edx,edx |
mov ecx,[rxs] |
div ecx |
cmp edx,0 |
jnz addx1 |
mov eax,[pos] |
jmp cm1 |
nolf: |
no_lf_ret: |
cmp bl,15 ; character |
jbe newdata |
mov eax,[irc_data] |
shl eax,8 |
mov al,bl |
mov [irc_data],eax |
mov eax,[pos] |
call draw_data |
mov eax,[pos] |
add eax,1 |
cm1: |
mov ebx,[scroll+4] |
imul ebx,[rxs] |
cmp eax,ebx |
jb noeaxz |
mov esi,[text_start] |
add esi,[rxs] |
mov edi,[text_start] |
mov ecx,ebx |
cld |
rep movsb |
mov esi,[text_start] |
mov ecx,[rxs] |
imul ecx,61 |
add esi,ecx |
mov edi,[text_start] |
mov ecx,[rxs] |
imul ecx,60 |
add edi,ecx |
mov ecx,ebx |
cld |
rep movsb |
mov eax,ebx |
sub eax,[rxs] |
noeaxz: |
mov [pos],eax |
newdata: |
mov eax,[text_start] |
mov [eax+120*60],byte 1 |
popa |
ret |
read_incoming_byte: |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socket] |
int 0x40 |
mov ecx,-1 |
cmp eax,0 |
je no_more_data |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socket] |
int 0x40 |
mov ecx,0 |
no_more_data: |
ret |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; |
;; Window definitions |
;; |
draw_window: |
pusha |
mov eax,12 |
mov ebx,1 |
int 0x40 |
mov eax,0 ; draw window |
mov ebx,5*65536+435 |
mov ecx,5*65536+232 |
mov edx,[wcolor] |
add edx,0x03ffffff |
mov esi,0x80555599 |
mov edi,0x00ffffff |
int 0x40 |
mov [old_status],300 |
mov eax,4 ; label |
mov ebx,9*65536+8 |
mov ecx,0x10ffffff |
mov edx,labelt |
mov esi,labellen-labelt |
int 0x40 |
mov eax,8 ; button: open socket |
mov ebx,23*65536+22 |
mov ecx,155*65536+10 |
mov edx,22 |
mov esi,0x44cc44 |
int 0x40 |
mov eax,8 ; button: close socket |
mov ebx,295*65536+22 |
mov ecx,155*65536+10 |
mov edx,24 |
mov esi,0xcc4444 |
int 0x40 |
mov eax,8 ; button: text entries |
mov ebx,243*65536+8 |
mov ecx,180*65536+8 |
mov edx,51 |
mov esi,0x4488dd |
newi: |
int 0x40 |
inc edx |
add ecx,12*65536 |
cmp edx,53 |
jbe newi |
mov eax,8 ; open inbox |
mov ebx,295*65536+102 |
mov ecx,190*65536+14 |
mov edx,60 |
mov esi,0x5577dd |
int 0x40 |
mov eax,38 ; line |
mov ebx,5*65536+430 |
mov ecx,114*65536+114 |
mov edx,0x000000 |
int 0x40 |
mov ebx,5*65536+133 ; info text |
mov ecx,0x000000 |
mov edx,text |
mov esi,70 |
newline: |
mov eax,4 |
int 0x40 |
add ebx,12 |
add edx,70 |
cmp [edx],byte 'x' |
jne newline |
mov edx,I_END ; text from server |
call draw_server_data |
mov eax,12 |
mov ebx,2 |
int 0x40 |
popa |
ret |
draw_server_data: |
pusha |
mov eax,4 |
mov ebx,10*65536+26 |
mov ecx,8 |
mov esi,[rxs] |
dct: |
pusha |
mov cx,bx |
shl ecx,16 |
mov cx,9 |
mov eax,13 |
mov ebx,10*65536 |
mov bx,word [rxs] |
imul bx,6 |
mov edx,0xffffff |
int 0x40 |
popa |
push ecx |
mov eax,4 |
mov ecx,0 |
int 0x40 |
add edx,[rxs] |
add ebx,10 |
pop ecx |
loop dct |
popa |
ret |
text: |
db ' Incoming mails are written to /rd/1/popc.txt ' |
db ' ' |
db ' Check for mail. Force close ' |
db ' ' |
ip_text: |
db ' Server IP : 192.168.1.200 < ' |
l2_text: |
db ' User : < Open popc.txt ' |
l3_text: |
db ' Password : (not shown) < ' |
db 'x <- END MARKER, DONT DELETE ' |
file_start dd 0x100000 |
files: |
dd 1,0,0,0x100000,0xd0000 |
db '/rd/1/popc.txt',0 |
filel: |
dd 0,0,10000/512,0x100000,0xd0000 |
db '/rd/1/popc.txt',0 |
ip db 192,168,1,200 |
socket dd 0x0 |
posx dd 0x0 |
incoming_pos dd 0x0 |
incoming_string: times 128 db 0 |
pos dd 0x0 |
text_start dd I_END |
print db 0x0 |
cmd dd 0x0 |
rxs dd 66 |
res: db 0,0 |
command: times 256 db 0x0 |
command_position dd 0 |
counter dd 0 |
numtext db ' ' |
wcolor dd 0x000000 |
labelt db 'POP client v ',version |
labellen: |
scroll: dd 1,8 |
tp: db 'TINYPAD ' |
pr: db 'POPC TXT',0 |
getmail: |
db 'user xyz ',13,10 |
db 'pass xyz ',13,10 |
db 'retr 1 ',13,10 |
db 'retr 2 ',13,10 |
db 'retr 3 ',13,10 |
db 'retr 4 ',13,10 |
db 'retr 5 ',13,10 |
db 'retr 6 ',13,10 |
db 'retr 7 ',13,10 |
db 'retr 8 ',13,10 |
db 'retr 9 ',13,10 |
quitc: |
db 'quit ',13,10 |
mcounter dd 900 |
ccounter dd 0 |
ld db 13,10 |
server_active db 0 |
header_sent db 0 |
close_connection dd 0x0 |
mail_rp dd 0 |
irc_data dd 0x0 |
addr dd 0x0 |
ya dd 0x0 |
len dd 0x0 |
input1: times 50 db 32 |
input2: times 50 db 32 |
input3: times 50 db 32 |
l1 dd 0 |
l2 dd 3 |
l3 dd 3 |
status dd 0x0 |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/ppp/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm ppp.asm ppp |
@pause |
/programs/network/ppp/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm ppp.asm ppp |
@pause |
/programs/network/ppp/trunk/chat.inc |
---|
0,0 → 1,188 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; CHAT.INC ;; |
;; ;; |
;; Modem Chat Initiator for PPP Dialer ;; |
;; ;; |
;; Version 3 2nd May 2003 ;; |
;; ;; |
;; Copyright 2002 Shrirang Bhagwat, b_shrirang@hotmail.com ;; |
;; ;; |
;; See file COPYING for details ;; |
;; ;; |
;; 2/5/03 - Shrirang - Added Abort Strings For sendwait ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; Request And Response Chat Strings |
; Following Data Structure is used for Request Response Chatting |
; with the modem, for each request there is an expected response |
; chatreq <-> chatres, 0 (NULL) is delimeter for 1 string |
; '`' is delimiter for the section, modify according to your |
; modem dialing scheme; in future MenuetOS might provide a graphical |
; client to generate this kind of data structure and the PAP packet |
; for username and password! |
; Aborts strings are used to get outta sendwait early... |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; REQUESTS |
chatreq db 'ATH',13,0 ; 0 (NULL) is required by sendwait |
db 'ATZ',13,0 |
db 'ATM1',13,0 |
db 'ATX1',13,0 ; My Modem doesn't connect without this |
; db 'ATDT;',13,0 |
db 'ATDT phonenumber',13,0 |
db '`' ; <- End Marker |
; RESPONSES |
chatres db 'OK',0 |
db 'OK',0 |
db 'OK',0 |
db 'OK',0 |
; db 'OK',0 |
db 'CONNECT',0 |
db '`' ; <- End Marker |
; ABORTS |
aborts db 'ERROR',0 |
db 'NO CARRIER',0 |
db 'NO DIALTONE',0 |
db 'BUSY',0 |
db 'LINE IN USE',0 |
db 'NO ANSWER',0 |
db '`' ; <- End Marker |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; |
; modem_chat - chats with the modem to initiate a connection |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
modem_chat: |
push edi |
push esi |
push edx |
mov edi, chatreq ; init everytime, safe, stateless |
mov esi, chatres |
chat_now: |
cmp byte [esi], '`' ; are we done? |
je chatover |
mov edx, 6000 ; strings like "atdt;" take long on my modem |
call sendwait |
and eax, eax |
jz timeoutoccured |
updatereq: |
inc edi |
cmp byte [edi], '`' |
je updateres |
cmp byte [edi], 0 |
jne updatereq |
inc edi |
updateres: |
inc esi |
cmp byte [esi], '`' |
je chatover |
cmp byte [esi], 0 |
jne updateres |
inc esi |
jmp chat_now |
chatover: |
xor eax, eax ; SUCCESS! |
inc eax |
pop edx |
pop esi |
pop edi |
ret |
timeoutoccured: |
xor eax, eax ; FAIL! |
pop edx |
pop esi |
pop edi |
ret |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; |
; scanaborts - scans the response from modem for abort srings |
; ESI - Response from modem |
; EDI - Pointer to Abort Table |
; ECX - Response Length |
; Returns 1 if abort detected, 0 otherwise |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
scanaborts: |
push esi |
push edi |
push ecx |
checkit: |
push esi |
repe cmpsb ; any abort matches? |
je abortdetected |
pop esi |
updatetbl: |
inc edi |
cmp byte [edi], '`' |
je noabortfound |
cmp byte [edi], 0 |
jne updatetbl |
inc edi |
jmp checkit |
abortdetected: |
pop esi |
pop ecx |
pop edi |
pop esi |
xor eax, eax ; SUCCESS! |
inc eax |
ret |
noabortfound : |
pop ecx |
pop edi |
pop esi |
xor eax, eax ; FAILED! |
ret |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/ppp/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 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/ppp/trunk/ppp.asm |
---|
0,0 → 1,2255 |
; |
; PPP.ASM |
; |
; Compile with FASM for Menuet |
; This program dials into an ISP and establishes a PPP connection |
; |
; Version 11 26th January 2004 |
; |
; This code is a port of the PPP dialer program by Microchip, from |
; their application note AN724 |
; It has been ported by Mike Hibbett mikeh@oceanfree.net for Menuet |
; |
; 26/1/04 - Mike Hibbett - added support for com port selected by |
; stackcfg |
; 2/5/03 - Shrirang - Added Abort Strings To sendwait to get out early |
; if modem sends abort strings like NO CARRIER etc. |
; |
; The original copyright statement follows |
;////////////////////////////////////////////////////////////////////////// |
;// |
;//PING.C version 1.10 July 29/99 (C)opyright by Microchip Technology Inc |
;// |
;////////////////////////////////////////////////////////////////////////// |
FALSE equ 0 |
TRUE equ 1 |
DEBUG_OUTPUT equ TRUE ; If FALSE, not debugging info outputted |
DEBUG_PPP_OUTPUT equ TRUE ; write PPP status msgs to debug board? |
DEBUG_PORT2_OUTPUT equ TRUE ; write debug data also to com2 |
BAUD_9600 equ 12 |
BAUD_57600 equ 2 |
; The next line sets the baud rate of the connection to the modem |
BAUDRATE equ BAUD_57600 |
LINE_END equ 0x0D ; End of input data character |
; Defines for Internet constants |
REQ equ 1 ; Request options list for PPP negotiations |
PPP_ACK equ 2 ; Acknowledge options list for PPP negotiations |
PPP_NAK equ 3 ; Not acknowledged options list for PPP neg |
REJ equ 4 ; Reject options list for PPP negotiations |
TERM equ 5 ; Termination packet for LCP to close connectio |
LCP_ECHO_REQ equ 9 |
LCP_ECHO_REP equ 10 |
IP equ 0x0021 ; Internet Protocol packet |
IPCP equ 0x8021 ; Internet Protocol Configure Protocol packet |
CCP equ 0x80FD ; Compression Configure Protocol packet |
LCP equ 0xC021 ; Link Configure Protocol packet |
PAP equ 0xC023 ; Password Authenication Protocol packet |
MaxRx equ 1500 |
MaxTx equ 1500 |
use32 |
org 0x0 |
db 'MENUET00' ; 8 byte id |
dd 38 ; required os |
dd STARTAPP ; program start |
dd I_END ; program image size |
dd 0x100000 ; required amount of memory |
; esp = 0x7FFF0 |
dd 0x00000000 ; reserved=no extended header |
include "lang.inc" |
include "macros.inc" |
include "chat.inc" ; Hosts modem chatting routine |
STARTAPP: |
; mov eax, 0x3f8 |
; mov [comport], eax |
; mov eax, 4 |
; mov [comirq], eax |
; Get the com port & IRQ to use from the kernel stack config option |
mov eax, 52 ; Stack Interface |
mov ebx, 0 ; read configuration word |
int 0x40 |
mov ecx, eax |
shr ecx, 16 ; get the port address |
mov [comport], ecx |
shr eax, 8 |
and eax, 0x000000FF ; get the irq |
mov [comirq], eax |
mov eax, [comport] |
add eax, 0x01000000 |
mov [irqtable], eax |
call enable_port |
appdsp: |
mov eax, welcomep |
mov [prompt], eax ; set up prompt to display |
mov al, [welcomep_len] |
mov [prompt_len], al |
call draw_window ; at first, draw the window |
apploop: |
mov eax, 23 ; wait here for event |
mov ebx, 20 |
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 |
mov ebx, [comirq] |
add ebx, 16 |
cmp eax, ebx |
je flush_input ; Dont want serial data yet |
jmp apploop |
red: ; redraw |
call draw_window |
jmp apploop |
key: ; key - ignore |
mov eax, 2 ; just read it |
int 0x40 |
jmp apploop |
button: ; button |
mov eax, 17 ; get id |
int 0x40 |
cmp ah, 1 ; close program ? |
jne noclose |
mov esi, hangupWait |
mov edi, hangupSend |
mov edx, 1000 ; Allow sendwait 10s |
call sendwait |
call disable_port |
mov eax, -1 ; close this program |
int 0x40 |
jmp apploop |
noclose: |
cmp ah, 2 ; Dial Button pressed? |
jne apploop |
mov eax, conp |
mov [prompt], eax ; set up prompt to display |
mov al,[conp_len] |
mov [prompt_len], al |
call draw_window |
jmp dialloop ; connect to the host |
; Data received, so get it, and throw it away at this point |
flush_input: |
mov eax,42 |
mov ebx, [comirq] |
int 0x40 |
mov eax,11 ; This will return 0 most of the time |
int 0x40 |
mov ebx, [comirq] |
add ebx, 16 |
cmp eax, ebx |
je flush_input |
jmp apploop |
dialloop: |
call modem_chat ; Try chatting with the modem |
cmp eax, 1 ; Did it work? ( = 1) |
jne appdsp |
; OK, we are now connected. |
mov eax, pppOnp |
mov [prompt], eax ; set up prompt to display |
mov al,[pppOnp_len] |
mov [prompt_len], al |
call draw_window |
mov eax, 23 |
mov ebx, 100 |
int 0x40 ; wait for 1s to display message |
call PPPStateMachine ; This is the main code |
jmp appdsp |
;**************************************************************************** |
; Function |
; PPPStateMachine |
; |
; Description |
; Handles PPP link establishment |
; |
;**************************************************************************** |
PPPStateMachine: |
; Start the timer |
xor eax, eax |
call settimer |
PPPLoop: |
mov eax, 11 ; check event |
int 0x40 |
cmp eax, 3 |
jne PPPLred |
; button pressed |
mov eax, 17 ; get id |
int 0x40 |
mov eax, hangp |
mov [prompt], eax ; set up prompt to display |
mov al,[hangp_len] |
mov [prompt_len], al |
call draw_window |
mov esi, hangupWait |
mov edi, hangupSend |
mov edx, 1000 ; Allow sendwait 10s |
call sendwait |
call disable_port |
mov eax, -1 ; close this program |
int 0x40 |
jmp PPPLoop |
PPPLred: |
cmp eax, 1 ; redraw request ? |
jne PPPLoop0 |
call draw_window |
jmp PPPLoop |
PPPLoop0: |
mov ebx, [comirq] |
add ebx, 16 |
cmp eax, ebx |
jne ppp_002 ; check for tx to send |
; we have data in the rx buffer, get it |
mov eax, 42 |
mov ebx, [comirq] ; ecx will return 0 =data read, 1 =no data |
int 0x40 ; or 2 =not irq owner |
inc dword [rxbytes] |
cmp bl, 0x7E |
jne ppp_001a |
mov eax, [rx_ptr] |
cmp eax, 0 |
jz ppp_001 |
mov eax, [checksum1] |
cmp eax, 0xf0b8 |
jne ppp_001 |
movzx eax, byte [rx_str + 3] |
mov ah, [rx_str + 2] |
mov [packet], eax |
ppp_001: |
mov eax, [extended] |
and eax, 0x7e |
mov [extended], eax |
xor eax, eax |
mov [rx_ptr], eax |
mov eax, 0xffff |
mov [checksum1], eax |
jmp ppp_003 |
ppp_001a: |
cmp bl, 0x7D |
jne ppp_001b |
mov eax, [extended] |
or eax, 0x01 |
mov [extended], eax |
jmp ppp_003 |
ppp_001b: |
mov eax, [extended] |
test eax, 0x01 |
jz ppp_001c |
xor bl, 0x20 |
and eax, 0xFE |
mov [extended], eax |
ppp_001c: |
mov edx, [rx_ptr] |
cmp edx, 0 |
jnz ppp_001d |
cmp bl, 0xff |
je ppp_001d |
mov [rx_str + edx], byte 0xff |
inc edx |
ppp_001d: |
cmp edx, 1 |
jnz ppp_001e |
cmp bl, 0x03 |
je ppp_001e |
mov [rx_str + edx], byte 0x03 |
inc edx |
ppp_001e: |
cmp edx, 2 |
jnz ppp_001f |
test bl, 0x01 |
jz ppp_001f |
mov [rx_str + edx], byte 0 |
inc edx |
ppp_001f: |
mov [rx_str + edx], bl |
inc edx |
mov [rx_ptr], edx |
cmp edx, MaxRx |
jle ppp_001g |
mov edx, MaxRx |
mov [rx_ptr], edx |
ppp_001g: |
; do checksum calc |
mov eax, [checksum1] |
xor bh, bh |
xor ax, bx |
call calc |
mov ebx, [checksum1] |
and ebx, 0xffff |
shr ebx, 8 |
xor eax, ebx |
mov [checksum1], eax |
jmp ppp_003 |
ppp_002: |
mov eax, [tx_end] |
cmp eax, 0 |
jz ppp_003 |
mov ebx, [tx_ptr] |
mov cl, [tx_str + ebx] |
cmp ebx, eax |
jne ppp_002a |
mov [tx_end], dword 0 |
mov cl, '~' |
jmp ppp_002d |
ppp_002a: |
mov eax, [extended] |
and eax, 0x02 |
jz ppp_002b |
xor cl, 0x20 |
mov eax, [extended] |
and eax, 0xFD |
mov [extended], eax |
inc [tx_ptr] |
jmp ppp_002d |
ppp_002b: |
cmp cl, 0x20 |
jl ppp_002b1 |
cmp cl, 0x7d |
je ppp_002b1 |
cmp cl, 0x7e |
je ppp_002b1 |
jmp ppp_002c |
ppp_002b1: |
mov eax, [extended] |
or eax, 0x02 |
mov [extended], eax |
mov cl, 0x7d |
jmp ppp_002d |
ppp_002c: |
mov eax, [tx_ptr] |
cmp eax, 0 |
jnz ppp_002c1 |
mov cl, '~' |
ppp_002c1: |
inc [tx_ptr] |
ppp_002d: |
; Test for tx ready. |
push ecx |
wait_txd2: |
mov eax,43 |
mov ecx, [comport] |
add ecx, 0x80000000 + 5 |
int 0x40 |
and bl, 0x40 |
cmp bl, 0 |
jz wait_txd2 ; loop until free |
pop ebx |
; send the character |
inc dword [txbytes] |
mov ecx, [comport] |
mov eax, 43 |
int 0x40 |
ppp_003: |
mov eax, [packet] |
cmp eax, LCP |
jne ppp_004 |
mov al, [rx_str + 4] |
cmp al, REQ |
jne ppp_003b |
; Debugging output to debug board |
pusha |
mov esi, RX_LCP_REQ |
call debug_output |
popa |
mov eax, [state] |
and eax, 0xfd |
mov [state], eax |
mov ebx, 0xc6 |
push eax |
call TestOptions |
pop eax |
cmp edx, 0 |
jz ppp_003g |
cmp edx, 1 |
jle ppp_003h |
mov edx, PPP_ACK |
cmp eax, 3 |
jge ppp_003i |
or eax, 0x02 |
mov [state], eax |
jmp ppp_003i |
ppp_003h: |
mov bl, 0xc0 |
mov [rx_str + 10], bl |
mov edx, PPP_NAK |
jmp ppp_003i |
ppp_003g: |
mov edx, REJ |
ppp_003i: |
mov ebx, LCP |
mov ecx, edx |
movzx edx, byte [rx_str + 5] |
mov esi, rx_str + 7 |
call MakePacket |
mov eax, 0 |
call settimer |
jmp ppp_003a |
ppp_003b: |
cmp al, PPP_ACK |
jne ppp_003c |
; Debugging output to debug board |
pusha |
mov esi, RX_LCP_ACK |
call debug_output |
popa |
mov eax, [number] |
cmp al, [rx_str+5] |
jne ppp_003a |
mov eax, [state] |
cmp eax, 3 |
jge ppp_003a |
or eax, 0x01 |
mov [state], eax |
jmp ppp_003a |
ppp_003c: |
cmp al, PPP_NAK |
jne ppp_003d |
; Debugging output to debug board |
pusha |
mov esi, RX_LCP_NAK |
call debug_output |
popa |
mov eax, [state] |
and eax, 0xfe |
mov [state], eax |
jmp ppp_003a |
ppp_003d: |
cmp al, REJ |
jne ppp_003e |
; Debugging output to debug board |
pusha |
mov esi, RX_LCP_REJ |
call debug_output |
popa |
mov eax, [state] |
and eax, 0xfe |
mov [state], eax |
jmp ppp_003a |
ppp_003e: |
cmp al, TERM |
jne ppp_003j |
jmp ppp_003a |
ppp_003j: |
cmp al, LCP_ECHO_REQ |
jne ppp_003a |
; Debugging output to debug board |
pusha |
mov esi, RX_LCP_ECHO_REQ |
call debug_output |
popa |
mov al, 0 |
mov [rx_str+8],al |
mov [rx_str+9],al |
mov [rx_str+10],al |
mov [rx_str+11],al |
mov ebx, LCP |
mov ecx, LCP_ECHO_REP |
movzx edx, byte [rx_str + 5] |
mov esi, rx_str + 7 |
call MakePacket |
ppp_003a: |
mov eax, [state] |
cmp eax, 3 |
jne ppp_013 |
mov eax, 4 |
mov [state], eax |
jmp ppp_013 |
ppp_004: |
cmp eax, PAP |
jne ppp_005 |
mov al, [rx_str + 4] |
cmp al, PPP_ACK |
jne ppp_013 |
; Debugging output to debug board |
pusha |
mov esi, RX_PAP_ACK |
call debug_output |
popa |
mov eax, 5 |
mov [state],eax |
jmp ppp_013 |
ppp_005: |
cmp eax, IPCP |
jne ppp_006 |
mov al, [rx_str + 4] |
cmp al, REQ |
jne ppp_005a |
; Debugging output to debug board |
pusha |
mov esi, RX_IPCP_REQ |
call debug_output |
popa |
mov ebx, 0x04 |
call TestOptions |
cmp edx, 0 |
jz ppp_005b |
mov ecx, PPP_ACK |
mov eax, 6 |
mov [state], eax |
jmp ppp_005c |
ppp_005b: |
mov ecx, REJ |
ppp_005c: |
mov ebx, IPCP |
movzx edx, byte [rx_str + 5] |
mov esi, rx_str + 7 |
call MakePacket |
jmp ppp_013 |
ppp_005a: |
cmp al, PPP_ACK |
jne ppp_005d |
; Debugging output to debug board |
pusha |
mov esi, RX_IPCP_ACK |
call debug_output |
popa |
mov al, [rx_str + 5] |
mov ecx, [number] |
cmp al, cl |
jne ppp_013 |
mov eax, 7 |
mov [state], eax |
mov eax, 5800 |
call settimer |
mov eax, IPOnp |
mov [prompt], eax ; set up prompt to display |
mov al,[IPOnp_len] |
mov [prompt_len], al |
call draw_window |
jmp ppp_013 |
ppp_005d: |
cmp al, PPP_NAK |
jne ppp_005e |
; Debugging output to debug board |
pusha |
mov esi, RX_IPCP_NAK |
call debug_output |
popa |
mov al, [rx_str + 10] |
mov [addr1], al |
mov al, [rx_str + 11] |
mov [addr2], al |
mov al, [rx_str + 12] |
mov [addr3], al |
mov al, [rx_str + 13] |
mov [addr4], al |
pusha |
call draw_window |
mov eax,52 |
mov ebx,3 |
mov cl, [addr4] |
shl ecx, 8 |
mov cl, [addr3] |
shl ecx, 8 |
mov cl, [addr2] |
shl ecx, 8 |
mov cl, [addr1] |
int 0x40 ; Set the stacks IP address |
popa |
mov ebx, IPCP ;; added 28/4/03 |
mov ecx, REQ |
movzx edx, byte [rx_str + 5] |
mov esi, rx_str + 7 |
call MakePacket |
jmp ppp_013 |
ppp_005e: |
cmp al, REJ |
jne ppp_005f |
jmp ppp_013 |
ppp_005f: |
cmp al, TERM |
jne ppp_013 |
jmp ppp_013 |
ppp_006: |
cmp eax, IP |
jne ppp_007 |
;; |
;; |
;; |
;; This is where we will pass the IP packet up to the stack |
;; |
;; |
;; |
mov eax, 52 |
mov ebx, 6 |
mov edx, 1500 ; this should be exact amount |
mov esi, rx_str + 4 |
int 0x40 |
; Debugging output to debug board |
pusha |
mov esi, RX_IP |
call debug_output |
popa |
jmp ppp_013 |
ppp_007: |
cmp eax, CCP |
jne ppp_008 |
mov al, [rx_str + 4] |
cmp al, REQ |
jne ppp_013 |
; Debugging output to debug board |
pusha |
mov esi, RX_CCP_REQ |
call debug_output |
popa |
mov ebx, 0x04 |
call TestOptions |
cmp edx, 0 |
jz ppp_007b |
mov ecx, PPP_ACK |
jmp ppp_007c |
ppp_007b: |
mov ecx, REJ |
ppp_007c: |
mov ebx, CCP |
movzx edx, byte [rx_str + 5] |
mov esi, rx_str + 7 |
call MakePacket |
jmp ppp_013 |
ppp_008: |
cmp eax, 0 |
jz ppp_009 |
jmp ppp_013 |
ppp_009: |
mov eax, [tx_end] |
cmp eax, 0 |
jnz ppp_010 |
call gettimer |
cmp eax, 100 |
jle ppp_010 |
mov eax, [state] |
cmp eax, 0 |
je ppp_009a |
cmp eax, 2 |
jne ppp_010 |
ppp_009a: |
; Debugging output to debug board |
pusha |
mov esi, TX_LCP_REQ |
call debug_output |
popa |
inc [number] |
mov eax, 0 |
call settimer |
mov ebx, LCP |
mov ecx, REQ |
mov edx, [number] |
mov esi, LCPREQStr |
call MakePacket |
jmp ppp_013 |
ppp_010: |
mov eax, [tx_end] |
cmp eax, 0 |
jnz ppp_011 |
call gettimer |
cmp eax, 100 |
jle ppp_011 |
mov eax, [state] |
cmp eax, 4 |
jne ppp_011 |
mov eax, 0 |
call settimer |
inc [number] |
; Debugging output to debug board |
pusha |
mov esi, TX_PAP_REQ |
call debug_output |
popa |
mov ebx, PAP |
mov ecx, REQ |
mov edx, [number] |
mov esi, PAPREQStr |
call MakePacket |
jmp ppp_013 |
ppp_011: |
mov eax, [tx_end] |
cmp eax, 0 |
jnz ppp_012 |
call gettimer |
cmp eax, 100 |
jle ppp_012 |
mov eax, [state] |
cmp eax, 6 |
jne ppp_012 |
inc [number] |
mov eax, 0 |
call settimer |
; Debugging output to debug board |
pusha |
mov esi, TX_IPCP_REQ |
call debug_output |
popa |
mov ebx, IPCP |
mov ecx, REQ |
mov edx, [number] |
mov esi, IPCPREQStr |
call MakePacket |
jmp ppp_013 |
ppp_012: |
mov eax, [tx_end] |
cmp eax, 0 |
jnz ppp_013 |
mov eax, [state] |
cmp eax, 7 |
jne ppp_013 |
; 10ms Delay suggested by Ville |
mov eax,23 ; over here |
mov ebx,1 |
int 0x40 |
call gettimer |
cmp eax, 200 |
jle ppp_012a |
; every 2s, when things are quiet, redraw window |
call draw_window_limited |
mov eax, 0 |
call settimer |
ppp_012a: |
mov eax, 52 |
mov ebx, 8 |
mov esi, ip_buff |
int 0x40 |
cmp eax, 0 |
je ppp_013 |
call MakeIPPacket |
; Debugging output to debug board |
pusha |
mov esi, TX_IP |
call debug_output |
popa |
ppp_013: |
mov eax, [packet] |
cmp eax, 0 |
jz PPPLoop |
mov eax, 0 |
mov [packet], eax |
mov edi, rx_str |
mov ecx, MaxRx + 1 |
rep stosb |
jmp PPPLoop |
;**************************************************************************** |
; Function |
; calc |
; |
; Description |
; Adds a character to the CRC checksum |
; byte in lsb of eax |
; |
; |
;**************************************************************************** |
calc: |
and eax, 0xFF |
push ecx |
mov ecx, 8 |
calc_001: |
test al, 0x01 |
jz calc_002 |
shr eax, 1 |
xor eax, 0x8408 |
and eax, 0xffff |
jmp calc_003 |
calc_002: |
shr eax, 1 |
calc_003: |
loop calc_001 |
pop ecx |
ret |
;**************************************************************************** |
; Function |
; add2tx |
; |
; Description |
; Adds a character into the tx buffer |
; byte in low byte of eax |
; |
; |
;**************************************************************************** |
add2tx: |
pusha |
mov esi, tx_str |
add esi, [tx_ptr] |
inc [tx_ptr] |
mov [esi], al ; Save byte in buffer |
mov ecx, [checksum2] |
and eax, 0xff |
xor eax, ecx |
call calc |
shr ecx, 8 |
and ecx, 0xff |
xor eax, ecx |
mov [checksum2], eax |
popa |
ret |
;**************************************************************************** |
; Function |
; MakeIPPacket |
; |
; Description |
; Creates a PPP packet for transmission to the host from the |
; IP packet extracted from the stack |
; |
; IP data is in ip_buff |
; |
;**************************************************************************** |
MakeIPPacket: |
mov [tx_ptr], dword 1 |
mov edi, tx_str |
mov [edi], byte ' ' |
mov eax, 0xffff |
mov [checksum2], eax |
mov al, 0xff |
call add2tx |
mov al, 3 |
call add2tx |
mov al, IP / 256 |
call add2tx |
mov al, IP |
call add2tx |
movzx ecx, byte [ip_buff + 3] |
mov ch, byte [ip_buff + 2] |
mov esi, ip_buff |
mip001: |
mov al, byte [esi] |
call add2tx |
inc esi |
loop mip001 |
mov eax, [checksum2] |
not eax |
call add2tx |
shr eax, 8 |
call add2tx |
mov eax, [tx_ptr] |
mov [tx_end], eax |
xor eax, eax |
mov [tx_ptr], eax |
ret |
;**************************************************************************** |
; Function |
; MakePacket |
; |
; Description |
; Creates a PPP packet for transmission to the host |
; |
; Packet type in ebx |
; Code is in ecx |
; num is in edx |
; str is pointed to by esi |
; |
;**************************************************************************** |
MakePacket: |
mov [tx_ptr], dword 1 |
mov edi, tx_str |
mov [edi], byte ' ' |
mov eax, 0xffff |
mov [checksum2], eax |
mov al, 0xff |
call add2tx |
mov al, 3 |
call add2tx |
mov al, bh ; packet/256 |
call add2tx |
mov al, bl ; packet&255 |
call add2tx |
cmp ebx, IP ; is packet type IP? |
jne mp_001 ; No - its a lower layer packet |
; Do IP packet assembly |
jmp mp_002 |
mp_001: |
; Do PPP layer packet assembly |
mov al, cl |
call add2tx |
mov al, dl |
call add2tx |
mov al, 0 |
call add2tx |
movzx ecx, byte [esi] ; length = *str - 3 |
sub ecx, 3 |
mp_002: ; Now copy the data acros |
mov al, byte [esi] |
call add2tx |
inc esi |
loop mp_002 |
mov eax, [checksum2] |
not eax |
call add2tx |
shr eax, 8 |
call add2tx |
mov eax, [tx_ptr] |
mov [tx_end], eax |
xor eax, eax |
mov [tx_ptr], eax |
ret |
;**************************************************************************** |
; Function |
; TestOptions |
; |
; Description |
; Test a PPP packets options fields for valid entries |
; |
; option ebx |
; |
; Returns result in edx, but may also modify rx_str |
; |
;**************************************************************************** |
TestOptions: |
mov esi, 8 ; ptr1 |
mov edi, 8 ; ptr2 |
mov edx, 3 ; edx is the return value |
movzx ecx, byte [rx_str + 7] |
add ecx, 4 ; ecx is size |
cmp ecx, MaxRx |
jle to_001 |
mov ecx, MaxRx |
to_001: |
cmp esi, ecx |
jge to_002 |
mov al, byte [esi + rx_str] |
cmp al, 3 |
jne to_001a |
mov al, byte [esi + rx_str + 2] |
cmp al, 0x80 |
je to_001a |
; bug fix for chap authenticate reject below |
mov al, byte [esi + rx_str + 2] |
cmp al, 0xc2 |
jne to_001a |
and edx, 0xfd |
to_001a: |
push ecx |
mov cl, [esi + rx_str] |
dec cl |
mov eax, 1 |
shl eax, cl |
and eax, ebx |
and eax, 0xffff |
pop ecx |
cmp eax, 0 |
jnz to_001b |
xor edx,edx |
to_001b: |
movzx eax, byte [esi+rx_str+1] |
add esi, eax |
jmp to_001 |
to_002: |
; if (!(pass&2))... |
test edx, 2 |
jnz to_exit |
test edx, 1 |
jz to_002a |
mov ebx, 0xFFFB |
to_002a: |
mov esi, 8 |
to_002b: ; for loop |
cmp esi, ecx |
jge to_003 |
push ecx |
mov cl, [esi + rx_str] |
dec cl |
mov eax, 1 |
shl eax, cl |
and eax, ebx |
and eax, 0xffff |
pop ecx |
cmp eax, 0 |
jnz to_002c |
movzx edx, byte [esi+rx_str+1] |
to_002d: |
cmp esi, ecx |
jge to_002b |
cmp edx, 0 |
jz to_002b |
mov al, [esi + rx_str] |
mov [edi + rx_str], al |
inc esi |
inc edi |
dec edx |
jmp to_002d |
to_002c: |
movzx eax, byte [esi+rx_str+1] |
add esi, eax |
jmp to_002b ; end of for loop |
to_003: |
mov eax, edi |
sub al, 4 |
mov [rx_str+7], al |
xor edx, edx |
cmp ebx, 0xfffb |
jne to_exit |
inc edx |
to_exit: |
; Return value in EDX |
ret |
;*************************************************************************** |
; Function |
; disable_port |
; |
; Description; |
; Releases this applications use of the com port |
; |
;*************************************************************************** |
disable_port: |
if DEBUG_PORT2_OUTPUT = TRUE |
mov eax, 46 ; free port area |
mov ebx, 1 |
mov ecx, 0x2f8 |
and ecx, 0xFF0 |
mov edx, ecx |
or edx, 0x00F |
int 0x40 |
end if |
mov eax, 45 ; free irq 4 |
mov ebx, 1 |
mov ecx, [comirq] |
int 0x40 |
mov eax, 46 ; free port area |
mov ebx, 1 |
mov ecx, [comport] |
and ecx, 0xFF0 |
mov edx, ecx |
or edx, 0x00F |
int 0x40 |
ret |
;*************************************************************************** |
; Function |
; enable_port |
; |
; Description; |
; Takes control of the com port, defining the IRQ table and initialising |
; the uart chip. |
; |
;*************************************************************************** |
enable_port: |
pusha |
if DEBUG_PORT2_OUTPUT = TRUE |
mov eax, 46 |
mov ebx, 0 |
mov ecx, 0x2f8 |
and ecx, 0xFF0 |
mov edx, ecx |
or edx, 0x00F |
int 0x40 ; reseve port memory to this process |
mov eax, 45 ; reserve irq 3 |
mov ebx, 0 |
mov ecx, 3 |
int 0x40 |
mov ecx, 0x2f8 ; data format register |
add ecx, 3 |
mov bl, 0x80 ; enable access to divisor latch |
mov eax, 43 ; send data to device - com port setup |
int 0x40 |
mov ecx, 0x2f8 ; interrupt enable register |
inc ecx |
mov bl, 0 ; No interruts enabled |
mov eax, 43 ; send data to device (modem) |
int 0x40 |
mov ecx, 0x2f8 ; Divisor latch LSB |
mov bl, BAUDRATE ; set baud rate |
mov eax, 43 ; send data to device (modem) |
int 0x40 |
mov ecx, 0x2f8 ; Data format register |
add ecx, 3 |
mov bl, 3 ; 8 data bits |
mov eax, 43 ; send data to device (modem) |
int 0x40 |
mov ecx, 0x2f8 ; Modem control register |
add ecx, 4 ; ** bl must be 0x0b for modem to dial! |
mov bl, 0x0b ; 0x08 -> out2 enabled. No handshaking. |
; 0xb -> out2 enabled, RTS/DTR enabled |
mov eax, 43 ; send data to device (modem) |
int 0x40 |
; mov ecx, 0x2f8 ; interrupt enable register |
; inc ecx |
; mov bl, 1 ; rx data interrupt enabled, othrs not |
; mov eax, 43 ; send data to device (modem) |
; int 0x40 |
end if |
mov eax, 46 |
mov ebx, 0 |
mov ecx, [comport] |
and ecx, 0xFF0 |
mov edx, ecx |
or edx, 0x00F |
int 0x40 ; reseve port memory to this process |
mov eax, 45 ; reserve irq 4 |
mov ebx, 0 |
mov ecx, [comirq] |
int 0x40 |
mov eax, 44 ; setup irq table |
mov ebx, irqtable |
mov ecx, [comirq] |
int 0x40 |
mov ecx, [comport] ; data format register |
add ecx, 3 |
mov bl, 0x80 ; enable access to divisor latch |
mov eax, 43 ; send data to device - com port setup |
int 0x40 |
mov ecx, [comport] ; interrupt enable register |
inc ecx |
mov bl, 0 ; No interruts enabled |
mov eax, 43 ; send data to device (modem) |
int 0x40 |
mov ecx, [comport] ; Divisor latch LSB |
mov bl, BAUDRATE ; set baud rate |
mov eax, 43 ; send data to device (modem) |
int 0x40 |
mov ecx, [comport] ; Data format register |
add ecx, 3 |
mov bl, 3 ; 8 data bits |
mov eax, 43 ; send data to device (modem) |
int 0x40 |
mov ecx, [comport] ; Modem control register |
add ecx, 4 ; ** bl must be 0x0b for modem to dial! |
mov bl, 0x0b ; 0x08 -> out2 enabled. No handshaking. |
; 0xb -> out2 enabled, RTS/DTR enabled |
mov eax, 43 ; send data to device (modem) |
int 0x40 |
mov ecx, [comport] ; interrupt enable register |
inc ecx |
mov bl, 1 ; rx data interrupt enabled, othrs not |
mov eax, 43 ; send data to device (modem) |
int 0x40 |
mov ecx, [comirq] |
add ecx, 16 |
mov ebx, 1 |
shl ebx, cl |
add ebx, 111b |
mov eax,40 ; enable irq 4 data |
int 0x40 |
popa |
ret |
;************************************************************************** |
; Function |
; draw_window |
; |
; Description; |
; Normal window definition and text layout for application |
;************************************************************************** |
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+250 ; [x start] *65536 + [x size] |
mov ecx, 100*65536+150 ; [y start] *65536 + [y size] |
mov edx,0x03224466 ; color of work area RRGGBB |
mov esi,0x00334455 ; color of grab bar RRGGBB |
mov edi,0x00ddeeff ; 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, labelt ; pointer to text beginning |
mov esi, labellen-labelt ; text length |
int 0x40 |
; DIAL BUTTON |
mov eax, 8 ; function 8 : define and draw button |
mov ebx, (50)*65536+40 ; [x start] *65536 + [x size] |
mov ecx, 130*65536+12 ; [y start] *65536 + [y size] |
mov edx, 2 ; button id |
mov esi, 0x5599cc ; button color RRGGBB |
int 0x40 |
mov ebx, 55*65536+133 ; Draw button text |
mov ecx, 0x00FFFFFF |
mov edx, button1_text |
xor eax, eax |
mov al, [button1_text_len] |
mov esi, eax |
mov eax, 4 |
int 0x40 |
; DISCONNECT BUTTON |
mov eax, 8 ; function 8 : define and draw button |
mov ebx, (150)*65536+65 ; [x start] *65536 + [x size] |
mov ecx, 130*65536+12 ; [y start] *65536 + [y size] |
mov edx, 3 ; button id |
mov esi, 0x5599cc ; button color RRGGBB |
int 0x40 |
mov ebx, 155*65536+133 ; Draw button text |
mov ecx, 0x00FFFFFF |
mov edx, button3_text |
xor eax, eax |
mov al, [button3_text_len] |
mov esi, eax |
mov eax, 4 |
int 0x40 |
mov ebx, 5*65536+40 ; draw info text with function 4 |
mov ecx, 0x00FFFFFF |
mov edx, [prompt] |
xor eax, eax |
mov al, [prompt_len] |
mov esi, eax |
mov eax, 4 |
int 0x40 |
; Draw IP address |
mov edx, 10*65536+60 |
mov esi, 0x00FFFFFF |
mov ebx, 0x00030000 |
movzx ecx, byte [addr1] |
mov eax, 47 |
int 0x40 |
mov edx, 31*65536+60 |
mov esi, 0x00FFFFFF |
mov ebx, 0x00030000 |
movzx ecx, byte [addr2] |
mov eax, 47 |
int 0x40 |
mov edx, 52*65536+60 |
mov esi, 0x00FFFFFF |
mov ebx, 0x00030000 |
movzx ecx, byte [addr3] |
mov eax, 47 |
int 0x40 |
mov edx, 73*65536+60 |
mov esi, 0x00FFFFFF |
mov ebx, 0x00030000 |
movzx ecx, byte [addr4] |
mov eax, 47 |
int 0x40 |
; Status byte |
mov edx, 100*65536+60 |
mov esi, 0x00FFFFFF |
mov ebx, 0x00010000 |
movzx ecx, byte [state] |
mov eax, 47 |
int 0x40 |
; bytes sent / received |
mov eax, 4 ; function 4 : write text to window |
mov ebx, 10*65536+80 ; [x start] *65536 + [y start] |
mov ecx, 0x00ffffff ; color of text RRGGBB |
mov edx, txmsg ; pointer to text beginning |
mov esi, txmsglen-txmsg ; text length |
int 0x40 |
mov eax, 4 ; function 4 : write text to window |
mov ebx, 10*65536+100 ; [x start] *65536 + [y start] |
mov ecx, 0x00ffffff ; color of text RRGGBB |
mov edx, rxmsg ; pointer to text beginning |
mov esi, rxmsglen-rxmsg ; text length |
int 0x40 |
call draw_window_limited |
mov eax, 12 ; end of redraw |
mov ebx, 2 |
int 0x40 |
ret |
draw_window_limited: |
mov eax,13 |
mov ebx,80*65536+10*6 |
mov ecx,80*65536+10 |
mov edx,0x03224466 |
int 0x40 |
mov eax,13 |
mov ebx,80*65536+10*6 |
mov ecx,100*65536+10 |
mov edx,0x03224466 |
int 0x40 |
mov ebx, 0x000A0000 |
mov ecx, [txbytes] |
mov esi, 0x00ffffff ; color of text RRGGBB |
mov eax, 47 ; function 47 : write number to window |
mov edx, 80*65536+80 ; [x start] *65536 + [y start] |
int 0x40 |
mov ebx, 0x000A0000 |
mov ecx, [rxbytes] |
mov esi, 0x00ffffff ; color of text RRGGBB |
mov eax, 47 ; function 47 : write number to window |
mov edx, 80*65536+100 ; [x start] *65536 + [y start] |
int 0x40 |
ret |
;**************************************************************************** |
; Function |
; settimer |
; |
; Description |
; sets the general purpose timer to a given value in eax |
; All times are in 1/100s |
; |
; |
;**************************************************************************** |
settimer: |
push eax |
mov eax, 26 |
mov ebx, 9 |
int 0x40 ; get 100th second counter |
pop ebx |
sub eax, ebx ; This could have some funny side effecs if PPP |
; called within ebx seconds of startup |
mov [timerValue], eax |
ret |
;**************************************************************************** |
; Function |
; gettimer |
; |
; Description |
; gets the general purpose timer count in eax |
; All times are in 1/100s |
; |
; |
;**************************************************************************** |
gettimer: |
mov eax, 26 |
mov ebx, 9 |
int 0x40 ; get 100th second counter |
sub eax, [timerValue] |
ret |
;**************************************************************************** |
; Function |
; sendwait |
; |
; Description |
; Sends a command string to the modem, then waits for a defined rsp |
; |
; esi points to string to wait for |
; edi points to string to send |
; edx holds wait time, in ms |
; |
; Returns 1 if OK or 0 if timeout occurred |
; |
;**************************************************************************** |
sendwait: |
mov [sendwaitTime], edx |
; Shrirang 2/5/03 |
mov byte [abortcnt], 0 ; reset the abort counter |
;--! |
; Start the timer |
xor eax, eax |
call settimer |
; Check for incoming data |
xor edx, edx |
xor eax, eax |
sw_001: |
push eax |
push edx |
; Has connection timer expired? |
call gettimer |
cmp eax, [sendwaitTime] |
jl sw_000 |
pop edx |
pop eax |
xor eax, eax |
jmp sw_exit ; Exit indicating an error ( timeout ) |
sw_000: |
; any data from modem? |
mov eax,11 ; This will return 0 most of the time |
int 0x40 |
mov ecx, eax |
pop edx |
pop eax |
cmp ecx, 1 ; redraw request ? |
je red1 |
cmp ecx, 3 ; button in buffer ? |
je button1 |
mov ebx, [comirq] |
add ebx, 16 |
cmp ecx,ebx |
jne sw_002 |
jmp sw_000a |
red1: |
pusha |
call draw_window |
popa |
push eax |
push edx |
jmp sw_000 |
button1: |
mov eax, 0 |
jmp sw_exit |
sw_000a: |
; there was data, so get it |
push edx |
push eax |
mov eax,42 |
mov ebx, [comirq] |
int 0x40 |
pop eax |
pop edx |
; Shrirang 2/5/03 |
; Now that the expected response is not got we check if we |
; got the abort part, before we reset the fsm |
cmp bl, 0x0d ; AT commands normally start and end with \r\n |
je checkabort |
cmp bl, 0x0a |
je checkabort |
push eax |
xor eax, eax |
mov al, [abortcnt] |
mov byte [abortres+eax], bl ; update abort response |
inc byte [abortcnt] |
pop eax |
jmp noabort |
checkabort : |
cmp byte [abortcnt], 2 ; if we got valid abort this cannot happen! |
jbe noabortflush |
push eax |
push esi |
push edi |
push ecx |
mov esi, abortres |
mov edi, aborts |
xor ecx, ecx |
mov cl, byte [abortcnt] |
call scanaborts ; scan 'em |
pop ecx |
pop edi |
pop esi |
and eax, eax |
jz noabortdec |
pop eax |
xor eax, eax |
jmp sw_exit |
noabortdec: |
pop eax |
noabortflush: |
mov byte [abortcnt], 0 |
noabort: |
;--! |
cmp [esi+edx], bl |
je sw_003 |
xor edx, edx |
; Added 28/4/03 |
cmp [esi+edx], bl |
je sw_003 |
jmp sw_001 |
sw_003: ; They are the same |
inc edx |
cmp [esi+edx], byte 0 |
jne sw_001 |
xor eax, eax |
inc eax |
jmp sw_exit |
sw_002: |
; Test for data to send to modem |
cmp [ edi + eax ], byte 0 |
je sw_001 |
; Is it a '|' character? |
cmp [ edi + eax ], byte '|' |
jne sw_004 |
push eax |
call gettimer |
cmp eax, 100 |
pop eax |
jl sw_001 |
; restart the timer |
push eax |
xor eax, eax |
call settimer |
pop eax |
; Move to next character |
inc eax |
jmp sw_001 |
sw_004: |
push edx |
push eax |
; restart the timer |
xor eax, eax |
call settimer |
; Test for tx ready. |
; OR, wait then send |
push edi |
mov eax, 5 |
mov ebx, 1 |
int 0x40 ; 10ms delay |
pop edi |
; send the character |
pop eax |
mov bl, [edi + eax] |
mov ecx, [comport] |
inc eax |
push eax |
mov eax, 43 |
int 0x40 |
pop eax |
pop edx |
cmp [ edi + eax ], byte 0 |
jne sw_001 |
cmp [ esi + edx ], byte 0 |
jne sw_001 |
xor eax, eax |
inc eax |
sw_exit: |
; return success (1) or failure (0) in eax |
ret |
if DEBUG_OUTPUT = TRUE |
;**************************************************************************** |
; Function |
; debug_output |
; |
; Description |
; prints a description of the PPP protocol's data exchanges to the |
; debug board |
; |
; esi holds ptr to msg to display |
; |
; Nothing preserved; I'm assuming a pusha/popa is done before calling |
; |
;**************************************************************************** |
debug_output: |
cmp esi, RX_IP |
jne do_001 |
call debug_print_string |
call debug_print_rx_ip |
mov esi, IP_DATA1 |
call debug_print_string |
mov esi, CRLF |
call debug_print_string |
mov esi, IP_DATA2 |
call debug_print_string |
ret |
do_001: |
cmp esi, TX_IP |
jne do_002 |
call debug_print_string |
call debug_print_tx_ip |
mov esi, IP_DATA1 |
call debug_print_string |
mov esi, CRLF |
call debug_print_string |
mov esi, IP_DATA2 |
call debug_print_string |
ret |
do_002: |
; Print PPP protocol information |
if DEBUG_PPP_OUTPUT = TRUE |
call debug_print_string |
mov esi, CRLF |
call debug_print_string |
end if |
ret |
txCom2: |
push ecx |
wait_txd2t: |
mov eax,43 |
mov ecx,0x80000000 + 0x2f8 + 5 |
int 0x40 |
and bl, 0x40 |
cmp bl, 0 |
jz wait_txd2t ; loop until free |
pop ebx |
; send the character |
mov ecx, 0x2f8 |
mov eax, 43 |
int 0x40 |
ret |
;**************************************************************************** |
; Function |
; debug_print_string |
; |
; Description |
; prints a string to the debug board |
; |
; esi holds ptr to msg to display |
; |
; Nothing preserved; I'm assuming a pusha/popa is done before calling |
; |
;**************************************************************************** |
debug_print_string: |
mov cl, [esi] |
cmp cl, 0 |
jnz dps_001 |
ret |
dps_001: |
if DEBUG_PORT2_OUTPUT = TRUE |
pusha |
call txCom2 |
popa |
end if |
mov eax,63 |
mov ebx, 1 |
push esi |
int 0x40 |
pop esi |
inc esi |
jmp debug_print_string |
; This is used for translating hex to ASCII for display or output |
hexchars db '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' |
IP_DATA1 db 'TCP From: xxxxxxxx To: xxxxxxxx SrcP: xxxx DestP: xxxx',0 |
IP_DATA2 db 'Seq: xxxxxxxx Ack: xxxxxxxx Flags: xx dataLen: xxxx',13,10,0 |
debug_print_rx_ip: |
mov esi, rx_str + 4 ; The ip buffer address start |
mov edi, IP_DATA1 |
cmp [esi+9], byte 1 |
jne rnICMP |
mov eax,'ICMP' |
jmp drp |
rnICMP: |
cmp [esi+9], byte 6 |
jne rnTCP |
mov eax,'TCP ' |
jmp drp |
rnTCP: |
cmp [esi+9], byte 17 |
jne rnUDP |
mov eax,'UDP ' |
jmp drp |
rnUDP: |
drp: |
mov [edi], eax |
call fillData |
ret |
debug_print_tx_ip: |
mov esi, ip_buff ; The ip buffer address start |
mov edi, IP_DATA1 |
cmp [esi+9], byte 1 |
jne tnICMP |
mov eax,'ICMP' |
jmp dtp |
tnICMP: |
cmp [esi+9], byte 6 |
jne tnTCP |
mov eax,'TCP ' |
jmp dtp |
tnTCP: |
cmp [esi+9], byte 17 |
jne tnUDP |
mov eax,'UDP ' |
jmp dtp |
tnUDP: |
dtp: |
mov [edi], eax |
call fillData |
ret |
fillData: |
; Display from IP |
mov cl, [esi+12] |
mov edx, 11 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+13] |
mov edx, 13 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+14] |
mov edx, 15 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+15] |
mov edx, 17 |
call wbyte ; byte in cl, dest in edi+edx |
; Display to IP |
mov cl, [esi+16] |
mov edx, 24 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+17] |
mov edx, 26 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+18] |
mov edx, 28 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+19] |
mov edx, 30 |
call wbyte ; byte in cl, dest in edi+edx |
; Only display extra data for TCP |
cmp [esi+9], byte 6 ; TCP? |
je nTCP |
; display source port |
mov [edi+32], byte 0 |
mov edi, IP_DATA2 |
mov [edi], byte 0 |
ret |
nTCP: |
mov [edi+32], byte ' ' |
mov cl, [esi+20] |
mov edx, 39 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+21] |
mov edx, 41 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+22] |
mov edx, 51 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+23] |
mov edx, 53 |
call wbyte ; byte in cl, dest in edi+edx |
mov edi, IP_DATA2 |
mov [edi], byte 'S' |
mov cl, [esi+24] |
mov edx, 5 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+25] |
mov edx, 7 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+26] |
mov edx, 9 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+27] |
mov edx, 11 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+28] |
mov edx, 19 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+29] |
mov edx, 21 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+30] |
mov edx, 23 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+31] |
mov edx, 25 |
call wbyte ; byte in cl, dest in edi+edx |
mov cl, [esi+33] |
and cl, 0x3F |
mov edx, 35 |
call wbyte ; byte in cl, dest in edi+edx |
; Display the size of the received packet |
mov dh, [esi + 2] |
mov dl, [esi + 3] |
sub dx, 40 |
mov cl, dh |
mov edx, 48 |
call wbyte ; byte in cl, dest in edi+edx |
mov dh, [esi + 2] |
mov dl, [esi + 3] |
sub dx, 40 |
mov cl, dl |
mov edx, 50 |
call wbyte ; byte in cl, dest in edi+edx |
ret |
wbyte: ; byte in cl, dest in edi+edx, edi unchanged |
xor eax, eax |
mov al, cl |
shr al, 4 |
mov bl, [eax + hexchars] |
mov [edi+edx], bl |
inc edx |
mov al, cl |
and al, 0x0f |
mov bl, [eax + hexchars] |
mov [edi+edx], bl |
ret |
else |
debug_output: |
ret |
end if |
; DATA AREA |
; debug msgs |
RX_IP db 'R: ',0 |
TX_IP db 'T: ',0 |
CRLF db 13,10,0 |
RX_LCP_REQ db 'RX_LCP_REQ',0 |
RX_LCP_ACK db 'RX_LCP_ACK',0 |
RX_LCP_NAK db 'RX_LCP_NAK',0 |
RX_LCP_REJ db 'RX_LCP_REJ',0 |
RX_LCP_ECHO_REQ db 'RX_LCP_ECHO_REQ',0 |
RX_PAP_ACK db 'RX_PAP_ACK',0 |
RX_IPCP_REQ db 'RX_IPCP_REQ',0 |
RX_IPCP_ACK db 'RX_IPCP_ACK',0 |
RX_IPCP_NAK db 'RX_IPCP_NAK ( IP Address assigned )',0 |
RX_CCP_REQ db 'RX_CCP_REQ',0 |
TX_LCP_REQ db 'TX_LCP_REQ',0 |
TX_PAP_REQ db 'TX_PAP_REQ',0 |
TX_IPCP_REQ db 'TX_IPCP_REQ',0 |
; Labels for GUI buttons |
button1_text db 'DIAL' |
button1_text_len db 4 |
button3_text db 'DISCONNECT' |
button3_text_len db 10 |
comport dd 0 |
comirq dd 0 |
; Pointer to prompt shown to user |
prompt dd 0 |
prompt_len db 0 |
; Application Title |
labelt db 'PPP Dialer' |
labellen: |
txmsg: db 'Tx bytes :' |
txmsglen: |
rxmsg: db 'Rx bytes :' |
rxmsglen: |
timerValue dd 0 |
sendwaitTime dd 0 |
; Prompts displayed to the user |
welcomep db 'Select an option below, see ppp.txt' |
welcomep_len db 35 |
dialfp db 'Connect Failed...' |
dialfp_len db 17 |
connectedp db 'Connected to Host' |
connectedp_len db 17 |
conp db 'Connecting to Host' |
conp_len db 18 |
pppOnp db 'PPP Started' |
pppOnp_len db 11 |
IPOnp db 'IP Link established' |
IPOnp_len db 19 |
discp db 'Disconnected from Host' |
discp_len db 22 |
hangp db 'Hanging up Modem......' |
hangp_len db 22 |
PPPconSend db 0x7e,0xff,0x7d,0x23,0x08,0x08,0x08,0x08,0 |
PPPconWait db '~~',0 |
hangupWait db 'ATZ',0 |
hangupSend db '|||+++|||',10,13,'ATH',10,13,'|ATZ',10,13,0 |
; Shrirang 2/5/03 |
abortres: times(50) db 0 |
abortcnt db 0 |
;--! |
LCPREQStr db 0x0e,0x02,0x06,0x00, 0x0a, 0x00, 0x00, 0x07, 0x02, 0x08, 0x02 |
PAPREQStr db 14, 4, 'free', 4, 'free' |
IPCPREQStr db 10, 3, 6, 0, 0, 0, 0 |
irqtable: dd 0x3f8 + 0x01000000 ; read port 0x3f8, byte |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
checksum1 dd 0 |
checksum2 dd 0 |
packet dd 0 |
state dd 0 |
extended dd 0 |
number dd 0 |
tx_end dd 0 |
tx_ptr dd 0 |
rx_ptr dd 0 |
addr1 db 0 |
addr2 db 0 |
addr3 db 0 |
addr4 db 0 |
rxbytes dd 0 |
txbytes dd 0 |
; End of application code and data marker |
I_END: |
rx_str: rb MaxRx + 1 |
tx_str: rb MaxTx + 1 |
ip_buff: rb 1500 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/rccc/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm rccc.asm rccc |
@pause |
/programs/network/rccc/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm rccc.asm rccc |
@pause |
/programs/network/rccc/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 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/rccc/trunk/rccc.asm |
---|
0,0 → 1,309 |
; |
; Remote Control Center(Client) |
; |
; ¢â®à: Hex |
; ©â: www.mestack.narod.ru |
; |
; ¯¨á ¨¥: |
; à®£à ¬¬ , ¯à¥¤ § ç¥ ï ¤«ï ã¯à ¢«¥¨ï 㤠«ñë¬ ª®¬¯ìîâ¥à®¬.«¨¥â᪠ï |
; ç áâì. |
; |
; Compile with FASM for Menuet |
; ®¬¯¨«¨àã¥âáï FASM'®¬ ¤«ï ¥ãíâ |
; |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; start of code |
dd I_END ; size of image |
dd 0x5000 ; memory for app |
dd 0x5000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Icon |
include 'lang.inc' |
include 'macros.inc' |
START: ; start of execution |
mov eax,53 ; open socket |
mov ebx,0 |
mov ecx,0x6000 ; local port |
mov edx,0x6100 ; remote port |
mov esi,dword [remote_ip] ; remote IP |
int 0x40 |
mov [socket], eax |
mov eax,53 ; send connect code |
mov ebx,4 |
mov ecx,[socket] |
mov edx,1 |
mov esi,connect |
int 0x40 |
call draw_window ; at first, draw the window |
still: |
mov eax,23 ; wait here for event |
mov ebx,1 |
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: |
call draw_window |
jmp still |
key: |
mov eax,2 |
int 0x40 |
jmp still |
button: |
mov eax,17 |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jnz noclose |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socket] |
int 0x40 |
mov eax,-1 |
int 0x40 |
noclose: |
cmp ah,2 ; SEND SHUTDOWN COMMAND? |
je send_shutdown |
cmp ah,3 ; SEND REBOOT COMMAND? |
je send_reboot |
cmp ah,4 ; SEND SAVEFI COMMAND? |
je send_savefi |
cmp ah,5 ; SEND SAVEHI COMMAND? |
je send_savehi |
cmp ah,6 ; SEND HOTREBOOT COMMAND? |
je send_hotreboot |
cmp ah,7 ; SEND EXIT COMMAND? |
je send_exit |
jmp still |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; SEND COMMANDS TO SERVER ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
send_shutdown: |
mov eax,53 ; SEND CODE TO REMOTE |
mov ebx,4 |
mov ecx,[socket] |
mov edx,1 |
mov esi,sen_shutdown |
int 0x40 |
jmp still |
send_reboot: |
mov eax,53 ; SEND CODE TO REMOTE |
mov ebx,4 |
mov ecx,[socket] |
mov edx,1 |
mov esi,sen_reboot |
int 0x40 |
jmp still |
send_savefi: |
mov eax,53 ; SEND CODE TO REMOTE |
mov ebx,4 |
mov ecx,[socket] |
mov edx,1 |
mov esi,sen_savefi |
int 0x40 |
jmp still |
send_savehi: |
mov eax,53 ; SEND CODE TO REMOTE |
mov ebx,4 |
mov ecx,[socket] |
mov edx,1 |
mov esi,sen_savehi |
int 0x40 |
jmp still |
send_hotreboot: |
mov eax,53 ; SEND CODE TO REMOTE |
mov ebx,4 |
mov ecx,[socket] |
mov edx,1 |
mov esi,sen_hotreboot |
int 0x40 |
jmp still |
send_exit: |
mov eax,53 ; SEND CODE TO REMOTE |
mov ebx,4 |
mov ecx,[socket] |
mov edx,1 |
mov esi,sen_exit |
int 0x40 |
jmp still |
get_data: |
mov eax,53 |
mov ebx,3 |
mov ecx,[socket] |
int 0x40 |
mov [edi],bl |
inc edi |
mov eax,53 |
mov ebx,2 |
mov ecx,[socket] |
int 0x40 |
cmp eax,0 |
jne get_data |
mov eax,4 |
mov ebx,30*65536+30 |
mov ecx,0x000000 |
mov edx,I_END |
mov esi,15 |
int 0x40 |
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+250 ; [x start] *65536 + [x size] |
mov ecx,60*65536+280 ; [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 ; CONTROL BUTTONS |
mov ebx,25*65536+9 |
mov ecx,113*65536+9 |
mov edx,2 |
mov esi,0x667788 |
int 0x40 |
newbut: |
int 0x40 |
add ecx,16*65536 |
inc edx |
cmp edx,8 |
jb newbut |
cld |
mov ebx,25*65536+50 ; draw info text with function 4 |
mov ecx,0x000000 |
mov edx,text |
mov esi,40 |
newline: |
mov eax,4 |
int 0x40 |
add ebx,16 |
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 ' ६ï á¥à¢¥à : ' |
db ' ' |
db ' ¥î ã¯à ¢«¥¨ï á¥à¢¥à®¬: ' |
db ' ' |
db ' - 몫îç¨âì ' |
db ' - ¥à¥§ £à㧨âì ' |
db ' - ®åà ¨âì ä«®¯¯¨-¨¬¥¤¦ ' |
db ' - ®åà ¨âì ¨¬¥¤¦ . ¤¨áª ' |
db ' - ®àï稩 à¥áâ àâ ï¤à ' |
db ' - ªàë⨥ á¥à¢¥à®© ç á⨠' |
db ' ' |
db ' ®ª «ìë© ¤à¥á : 192.168.0.1 ' |
db ' ¤ «ñë© ¤à¥á : 192.168.0.2 ' |
db '¤à¥á á¥à¢¥à - ¢ ª®æ¥ ¨á室¨ª ' |
db 'x <- END MARKER, DONT DELETE ' |
labeltext: db 'Remote Control Center(Client)' ; |
lte: |
socket dd 0x0 |
remote_ip db 192,168,0,2 |
sen_shutdown db 'S' |
sen_reboot db 'R' |
sen_savefi db 'F' |
sen_savehi db 'H' |
sen_hotreboot db 'O' |
sen_exit db 'E' |
connect db 'C' |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/rccs/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm rccs.asm rccs |
@pause |
/programs/network/rccs/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm rccs.asm rccs |
@pause |
/programs/network/rccs/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 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/rccs/trunk/rccs.asm |
---|
0,0 → 1,334 |
; |
; Remote Control Center(Server) |
; |
; ¢â®à: Hex |
; ©â: www.mestack.narod.ru |
; |
; ¯¨á ¨¥: |
; à®£à ¬¬ , ¯à¥¤ § ç¥ ï ¤«ï ã¯à ¢«¥¨ï 㤠«ñë¬ ª®¬¯ìîâ¥à®¬.¥à¢¥à ï |
; ç áâì. |
; |
; Compile with FASM for Menuet |
; ®¬¯¨«¨àã¥âáï FASM'®¬ ¤«ï ¥ãíâ |
; |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; start of code |
dd I_END ; size of image |
dd 0x5000 ; memory for app |
dd 0x5000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Icon |
include 'lang.inc' |
include 'macros.inc' |
remote_ip db 192,168,0,1 |
START: ; start of execution |
mov eax, 53 ; open receiver socket |
mov ebx, 0 |
mov ecx, 0x6100 ; local port |
mov edx, 0x6000 ; remote port |
mov esi, dword [remote_ip] ; remote IP |
int 0x40 |
mov [socket],eax |
mov [0],eax ; save for remote code |
call draw_window ; at first, draw the window |
still: |
mov eax,23 ; wait here for event |
mov ebx,1 |
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 |
mov eax,53 ; data from cluster terminal ? |
mov ebx,2 |
mov ecx,[socket] |
int 0x40 |
cmp eax,0 |
jne data_arrived |
jmp still |
red: |
call draw_window |
jmp still |
key: |
mov eax,2 |
int 0x40 |
jmp still |
button: |
mov eax,53 |
mov ebx,1 |
mov ecx,[socket] |
int 0x40 |
mov eax,-1 |
int 0x40 |
data_arrived: |
mov eax,5 ; wait a second for everything to arrive |
mov ebx,10 |
int 0x40 |
mov edi,I_END |
get_data: |
mov eax,53 |
mov ebx,3 |
mov ecx,[socket] |
int 0x40 |
mov [edi],bl |
inc edi |
mov eax,53 |
mov ebx,2 |
mov ecx,[socket] |
int 0x40 |
cmp eax,0 |
jne get_data |
cmp byte [I_END],'C' ;Connect ? |
jne no_con |
mov eax,4 |
mov ebx,10*65536+60 |
add ebx,[y] |
mov ecx,0x000000 |
mov edx,inp_con |
mov esi,29 |
int 0x40 |
add [y],10 |
jmp still |
no_con: |
cmp byte [I_END],'S' ; Shutdown ? |
jne no_shut |
mov eax,4 |
mov ebx,10*65536+60 |
add ebx,[y] |
mov ecx,0x000000 |
mov edx,inp_shut |
mov esi,26 |
int 0x40 |
add [y],10 |
mov eax,18 |
mov ebx,9 |
mov ecx,2 |
int 0x40 |
jmp still |
no_shut: |
cmp byte [I_END],'R' ; Reboot ? |
jne no_reb |
mov eax,4 |
mov ebx,10*65536+60 |
add ebx,[y] |
mov ecx,0x000000 |
mov edx,inp_reb |
mov esi,20 |
int 0x40 |
add [y],10 |
mov eax,18 |
mov ebx,9 |
mov ecx,3 |
int 0x40 |
jmp still |
no_reb: |
cmp byte [I_END],'F' ; Save image on floppi ? |
jne no_savefi |
mov eax,4 |
mov ebx,10*65536+60 |
add ebx,[y] |
mov ecx,0x000000 |
mov edx,inp_savefi |
mov esi,29 |
int 0x40 |
add [y],10 |
mov eax,18 |
mov ebx,9 |
mov ecx,1 |
int 0x40 |
jmp still |
no_savefi: |
cmp byte [I_END],'H' ; Save image on hard disk ? |
jne no_savehi |
mov eax,4 |
mov ebx,10*65536+60 |
add ebx,[y] |
mov ecx,0x000000 |
mov edx,inp_savehi |
mov esi,29 |
int 0x40 |
add [y],10 |
mov eax,18 |
mov ebx,6 |
mov ecx,2 |
int 0x40 |
jmp still |
no_savehi: |
cmp byte [I_END],'O' ; Hot reboot ? |
jne no_hotreb |
mov eax,4 |
mov ebx,10*65536+60 |
add ebx,[y] |
mov ecx,0x000000 |
mov edx,inp_hotreb |
mov esi,28 |
int 0x40 |
add [y],10 |
mov eax,18 |
mov ebx,9 |
mov ecx,4 |
int 0x40 |
jmp still |
no_hotreb: |
cmp byte [I_END],'E' ; Unload server ? |
jne no_com |
mov eax,4 |
mov ebx,10*65536+60 |
add ebx,[y] |
mov ecx,0x000000 |
mov edx,inp_exit |
mov esi,28 |
int 0x40 |
add [y],10 |
call button |
jmp still |
no_com: |
mov eax,4 |
mov ebx,10*65536+60 |
add ebx,[y] |
mov ecx,0x000000 |
mov edx,inp_com |
mov esi,22 |
int 0x40 |
add [y],10 |
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+300 ; [x start] *65536 + [x size] |
mov ecx,100*65536+330 ; [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 |
mov eax,8 |
mov ebx,(286-19)*65536+12 |
mov ecx,4*65536+12 |
mov edx,1 |
mov esi,0xaabbcc |
; 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 |
; Re-draw the screen text |
cld |
mov ebx,10*65536+30 ; draw info text with function 4 |
mov ecx,0x000000 |
mov edx,text |
mov esi,40 |
newline: |
mov eax,4 |
int 0x40 |
add ebx,16 |
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 ' ë© ¤à¥á : 192.168.0.2 ' |
db 'à®á«ã訢 ¥¬ë© ¯®àâ : 0x6100 ' |
db '®áâ®ï¨¥: ' |
db 'x <- END MARKER, DONT DELETE ' |
labeltext: db 'Remote Control Center(Server)' |
lte: |
socket dd 0x0 |
y dd 0x10 |
sysclock dd 0x0 |
inp_con db '¨¬ ¨¥, ¯®¤ª«î稫áï ª«¨¥â!' |
inp_shut db '¤ñ⠮⪫î票¥ á¨á⥬ë...' |
inp_reb db '¤ñâ ¯¥à¥§ £à㧪 ...' |
inp_savefi db '®åà 塞 ¨¬¥¤¦ ¤¨áª¥âã...' |
inp_savehi db '®åà 塞 ¨¬¥¤¦ . ¤¨áª...' |
inp_hotreb db '¤ñâ £®àï稩 à¥áâ àâ ï¤à ...' |
inp_exit db 'ë室 ¨§ ¯à®£à ¬¬ë...' |
inp_com db '¥®¯®§ ï ª®¬¬ ¤ !' |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/remote/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm remote.asm remote |
@pause |
/programs/network/remote/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm remote.asm remote |
@pause |
/programs/network/remote/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 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/remote/trunk/remote.asm |
---|
0,0 → 1,229 |
; |
; Remote processing example (remote node) - vt |
; |
; 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 0x100000 ; required amount of memory |
dd 0x00000000 ; reserved=no extended header |
include 'lang.inc' |
include 'macros.inc' |
remote_ip db 192,168,1,26 |
START: ; start of execution |
mov eax, 53 ; open receiver socket |
mov ebx, 0 |
mov ecx, 0x3000 ; local port |
mov edx, 0xffff ; remote port |
mov esi, dword [remote_ip] ; remote IP |
int 0x40 |
mov [socketNum],eax |
mov [0],eax ; save for remote code |
call draw_window ; at first, draw the window |
still: |
mov eax,23 ; wait here for event |
mov ebx,1 |
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 |
mov eax,53 ; data from cluster terminal ? |
mov ebx,2 |
mov ecx,[socketNum] |
int 0x40 |
cmp eax,0 |
jne data_arrived |
jmp still |
red: |
call draw_window |
jmp still |
key: |
mov eax,2 |
int 0x40 |
jmp still |
button: |
mov eax,53 |
mov ebx,1 |
mov ecx,[socketNum] |
int 0x40 |
mov eax,-1 |
int 0x40 |
data_arrived: |
mov eax,5 ; wait a second for everything to arrive |
mov ebx,10 |
int 0x40 |
mov edi,I_END |
get_data: |
mov eax,53 |
mov ebx,3 |
mov ecx,[socketNum] |
int 0x40 |
mov [edi],bl |
inc edi |
mov eax,53 |
mov ebx,2 |
mov ecx,[socketNum] |
int 0x40 |
cmp eax,0 |
jne get_data |
add byte [I_END+14],48 |
mov eax,4 |
mov ebx,10*65536+50 |
add ebx,[y] |
mov ecx,0x000000 |
mov edx,I_END |
mov esi,23 |
int 0x40 |
add [y],10 |
cmp byte [I_END+14],'1' ; DATA PACKET ? |
jne no_packet |
mov esi,I_END+23 |
mov edi,[I_END+15] |
mov ecx,[I_END+19] |
cld |
rep movsb |
jmp still |
no_packet: |
cmp byte [I_END+14],'2' ; EXECUTE ? |
jne no_execute |
mov eax,[I_END+15] |
call eax |
jmp still |
no_execute: |
jmp still |
y dd 0x10 |
; ********************************************* |
; ******* 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+286 ; [x start] *65536 + [x size] |
mov ecx,100*65536+330 ; [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 |
mov eax,8 |
mov ebx,(286-19)*65536+12 |
mov ecx,4*65536+12 |
mov edx,1 |
mov esi,0xaabbcc |
; 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 |
; Re-draw the screen text |
cld |
mov ebx,10*65536+30 ; draw info text with function 4 |
mov ecx,0x000000 |
mov edx,text |
mov esi,40 |
newline: |
mov eax,4 |
int 0x40 |
add ebx,16 |
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 'THIS NODE : 192.168.1.22 ' |
db 'LISTENING TO PORT : 0x3000 ' |
db 'x <- END MARKER, DONT DELETE ' |
labeltext: db 'CLUSTER REMOTE' |
lte: |
socketNum dd 0x0 |
send_data db 'MenuetRemote00' ; 00 header ; -> remote port 0x3000 |
db 1 ; 14 send |
dd 0x0 ; 15 position |
dd 0x0 ; 19 size |
; 23 |
execute db 'MenuetRemote00' ; 00 header ; -> remote port 0x3000 |
db 2 ; 14 execute |
dd 0x0 ; 15 position |
; 19 |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/rtdata/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm rtdata.asm rtdata |
@pause |
/programs/network/rtdata/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm rtdata.asm rtdata |
@pause |
/programs/network/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 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/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 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/smtps/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm smtps.asm smtps |
@pause |
/programs/network/smtps/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm smtps.asm smtps |
@pause |
/programs/network/smtps/trunk/smtps.asm |
---|
0,0 → 1,849 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; SMTP server for MenuetOS ;; |
;; ;; |
;; License: GPL / See file COPYING for details ;; |
;; Copyright 2002 (c) Ville Turjanmaa ;; |
;; ;; |
;; Compile with FASM for Menuet ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
include 'lang.inc' |
version equ '0.1' |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; required os |
dd START ; program start |
dd I_END ; program image size |
dd 0x200000 ; required amount of memory |
dd 0xffff0 |
dd 0,0 |
save_file: |
pusha |
cmp [file_start],0x100000+10 |
jbe nosub |
sub [file_start],8 |
nosub: |
mov edi,[file_start] |
mov eax,[file_start] |
sub eax,0x100000 |
mov [files+8],eax |
mov eax,58 |
mov ebx,files |
int 0x40 |
popa |
ret |
START: ; start of execution |
mov [file_start],0x100000 |
mov eax,58 |
mov ebx,filel |
int 0x40 |
cmp eax,0 |
jne notfound |
add [file_start],ebx |
notfound: |
mov edi,I_END |
mov ecx,60*120 |
mov eax,32 |
cld |
rep stosb |
mov eax,[rxs] |
imul eax,11 |
mov [pos],eax |
mov ebp,0 |
mov edx,I_END |
call draw_window ; at first, draw the window |
still: |
inc [cursor_on_off] |
mov eax,5 |
mov ebx,1 |
int 0x40 |
mov eax,11 ; wait here for event |
int 0x40 |
cmp eax,1 ; redraw |
je redraw |
cmp eax,2 ; key |
je key |
cmp eax,3 ; button |
je button |
cmp [I_END+120*60],byte 1 |
jne no_main_update |
mov [I_END+120*60],byte 0 |
mov edx,I_END |
call draw_channel_text |
no_main_update: |
cmp [server_active],0 |
je noread |
cmp [status],4 |
jne noread |
call read_incoming_data |
inc [close_connection] |
cmp [close_connection],15*100 |
jbe noread |
call yq |
noread: |
call print_status |
cmp [status],4 |
je check_header |
jmp still |
check_header: |
cmp [header_sent],1 |
je still |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov edx,6 |
mov esi,r220 |
int 0x40 |
mov [header_sent],1 |
jmp still |
redraw: ; redraw |
call draw_window |
jmp still |
button: ; button |
mov eax,17 ; get id |
int 0x40 |
cmp ah,1 ; close program |
jne noclose |
mov eax,-1 |
int 0x40 |
noclose: |
call socket_commands |
jmp still |
old_status dd 0x0 |
print_status: |
pusha |
mov eax,53 |
mov ebx,6 |
mov ecx,[socket] |
int 0x40 |
mov [status],eax |
cmp eax,[old_status] |
je no_print |
mov [old_status],eax |
push eax |
mov eax,13 |
mov ebx,360*65536+30 |
mov ecx,151*65536+10 |
mov edx,0xffffff |
int 0x40 |
pop ecx |
mov eax,47 |
mov ebx,3*65536 |
mov edx,360*65536+151 |
mov esi,0x000000 |
cmp [server_active],0 |
je no_print |
int 0x40 |
no_print: |
popa |
ret |
socket_commands: |
cmp ah,22 ; open socket |
jnz tst3 |
mov eax,3 |
int 0x40 |
mov [server_active],1 |
mov eax,53 |
mov ebx,5 |
mov ecx,25 ; local port # - http |
mov edx,0 ; no remote port specified |
mov esi,0 ; no remote ip specified |
mov edi,0 ; PASSIVE open |
int 0x40 |
mov [socket], eax |
ret |
tst3: |
cmp ah,24 ; close socket |
jnz no_24 |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
int 0x40 |
mov [header_sent],0 |
mov [mail_rp],0 |
mov [server_active],0 |
ret |
no_24: |
ret |
key: |
mov eax,2 |
int 0x40 |
jmp still |
read_incoming_data: |
pusha |
read_new_byte: |
call read_incoming_byte |
cmp ecx,-1 |
je no_data_in_buffer |
mov eax,[file_start] |
mov [eax],bl |
inc [file_start] |
cmp bl,10 |
jne no_start_command |
mov [cmd],1 |
no_start_command: |
cmp bl,13 |
jne no_end_command |
mov eax,[cmd] |
mov [eax+command-2],byte 0 |
call analyze_command |
mov edi,command |
mov ecx,250 |
mov eax,0 |
cld |
rep stosb |
mov [cmd],0 |
no_end_command: |
mov eax,[cmd] |
cmp eax,250 |
jge still |
mov [eax+command-2],bl |
inc [cmd] |
jmp read_new_byte |
no_data_in_buffer: |
popa |
ret |
analyze_command: |
pusha |
mov [text_start],I_END |
mov ecx,[rxs] |
imul ecx,11 |
mov [pos],ecx |
mov bl,13 |
call print_character |
mov bl,10 |
call print_character |
cmp [cmd],2 |
jbe nott |
mov ecx,[cmd] |
sub ecx,2 |
mov esi,command+0 |
newcmdc: |
mov bl,[esi] |
call print_character |
inc esi |
loop newcmdc |
nott: |
mov edx,I_END |
call draw_channel_text |
cmd_len_ok: |
cmp [command],dword 'data' |
je datacom |
cmp [command],dword 'DATA' |
je datacom |
cmp [command],dword 'Data' |
je datacom |
jmp nodatacom |
datacom: |
inc [mail_rp] |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov edx,6 |
mov esi,r354 |
int 0x40 |
mov [cmd],0 |
popa |
ret |
nodatacom: |
cmp [mail_rp],0 |
jne nomrp0 |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov edx,6 |
mov esi,r250 |
int 0x40 |
mov [cmd],0 |
popa |
ret |
nomrp0: |
cmp [command],dword 'QUIT' |
je yesquit |
cmp [command],dword 'Quit' |
je yesquit |
cmp [command],dword 'quit' |
je yesquit |
jmp noquit |
yq: |
pusha |
yesquit: |
mov [close_connection],0 |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov edx,6 |
mov esi,r221 |
int 0x40 |
mov [cmd],0 |
mov eax,5 |
mov ebx,5 |
int 0x40 |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
int 0x40 |
mov eax,5 |
mov ebx,5 |
int 0x40 |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
int 0x40 |
mov [header_sent],0 |
mov [mail_rp],0 |
call save_file |
mov eax,5 |
mov ebx,20 |
int 0x40 |
mov eax,53 |
mov ebx,5 |
mov ecx,25 ; local port # - http |
mov edx,0 ; no remote port specified |
mov esi,0 ; no remote ip specified |
mov edi,0 ; PASSIVE open |
int 0x40 |
mov [socket], eax |
popa |
ret |
noquit: |
cmp [command],byte '.' |
jne nodot |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov edx,6 |
mov esi,r250 |
int 0x40 |
mov [cmd],0 |
popa |
ret |
nodot: |
popa |
ret |
r250 db '250 ',13,10 |
r221 db '221 ',13,10 |
r220 db '220 ',13,10 |
r354 db '354 ',13,10 |
draw_data: |
pusha |
add eax,[text_start] |
mov [eax],bl |
popa |
ret |
print_text: |
pusha |
mov ecx,command-2 |
add ecx,[cmd] |
ptr2: |
mov bl,[eax] |
cmp bl,dl |
je ptr_ret |
cmp bl,0 |
je ptr_ret |
call print_character |
inc eax |
cmp eax,ecx |
jbe ptr2 |
ptr_ret: |
mov eax,[text_start] |
mov [eax+120*60],byte 1 |
popa |
ret |
print_character: |
pusha |
cmp bl,13 ; line beginning |
jne nobol |
mov ecx,[pos] |
add ecx,1 |
boll1: |
sub ecx,1 |
mov eax,ecx |
xor edx,edx |
mov ebx,[rxs] |
div ebx |
cmp edx,0 |
jne boll1 |
mov [pos],ecx |
jmp newdata |
nobol: |
cmp bl,10 ; line down |
jne nolf |
addx1: |
add [pos],dword 1 |
mov eax,[pos] |
xor edx,edx |
mov ecx,[rxs] |
div ecx |
cmp edx,0 |
jnz addx1 |
mov eax,[pos] |
jmp cm1 |
nolf: |
no_lf_ret: |
cmp bl,15 ; character |
jbe newdata |
mov eax,[irc_data] |
shl eax,8 |
mov al,bl |
mov [irc_data],eax |
mov eax,[pos] |
call draw_data |
mov eax,[pos] |
add eax,1 |
cm1: |
mov ebx,[scroll+4] |
imul ebx,[rxs] |
cmp eax,ebx |
jb noeaxz |
mov esi,[text_start] |
add esi,[rxs] |
mov edi,[text_start] |
mov ecx,ebx |
cld |
rep movsb |
mov esi,[text_start] |
mov ecx,[rxs] |
imul ecx,61 |
add esi,ecx |
mov edi,[text_start] |
mov ecx,[rxs] |
imul ecx,60 |
add edi,ecx |
mov ecx,ebx |
cld |
rep movsb |
mov eax,ebx |
sub eax,[rxs] |
noeaxz: |
mov [pos],eax |
newdata: |
mov eax,[text_start] |
mov [eax+120*60],byte 1 |
popa |
ret |
read_incoming_byte: |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socket] |
int 0x40 |
mov ecx,-1 |
cmp eax,0 |
je no_more_data |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socket] |
int 0x40 |
mov ecx,0 |
no_more_data: |
ret |
draw_window: |
pusha |
mov eax,12 |
mov ebx,1 |
int 0x40 |
mov [old_status],300 |
mov eax,0 ; draw window |
mov ebx,5*65536+400 |
mov ecx,5*65536+200 |
mov edx,[wcolor] |
add edx,0x03ffffff |
mov esi,0x80555599 |
mov edi,0x00ffffff |
int 0x40 |
mov eax,4 ; label |
mov ebx,9*65536+8 |
mov ecx,0x10ffffff |
mov edx,labelt |
mov esi,labellen-labelt |
int 0x40 |
mov eax,8 ; button: open socket |
mov ebx,23*65536+22 |
mov ecx,169*65536+10 |
mov edx,22 |
mov esi,0x55aa55 |
int 0x40 |
mov eax,8 ; button: close socket |
mov ebx,265*65536+22 |
mov ecx,169*65536+10 |
mov edx,24 |
mov esi,0xaa5555 |
int 0x40 |
mov eax,38 ; line |
mov ebx,5*65536+395 |
mov ecx,108*65536+108 |
mov edx,0x000000 |
int 0x40 |
mov ebx,5*65536+123 ; info text |
mov ecx,0x000000 |
mov edx,text |
mov esi,70 |
newline: |
mov eax,4 |
int 0x40 |
add ebx,12 |
add edx,70 |
cmp [edx],byte 'x' |
jne newline |
mov edx,I_END ; text from server |
call draw_channel_text |
mov eax,12 |
mov ebx,2 |
int 0x40 |
popa |
ret |
draw_channel_text: |
pusha |
mov eax,4 |
mov ebx,10*65536+26 |
mov ecx,[scroll+4] |
mov esi,[rxs] |
dct: |
pusha |
mov cx,bx |
shl ecx,16 |
mov cx,9 |
mov eax,13 |
mov ebx,10*65536 |
mov bx,word [rxs] |
imul bx,6 |
mov edx,0xffffff |
int 0x40 |
popa |
push ecx |
mov eax,4 |
mov ecx,0 |
cmp [edx],word '* ' |
jne no_red |
mov ecx,0xff0000 |
no_red: |
cmp [edx],word '**' |
jne no_light_blue |
cmp [edx+2],byte '*' |
jne no_light_blue |
mov ecx,0x0000ff |
no_light_blue: |
cmp [edx],byte '#' |
jne no_blue |
mov ecx,0x00ff00 |
no_blue: |
int 0x40 |
add edx,[rxs] |
add ebx,10 |
pop ecx |
loop dct |
popa |
ret |
text: |
db ' Incoming mails are written to /rd/1/smtps.txt ' |
db ' The file can be fetched with TinyServer and a Html-browser. ' |
db ' Timeout is set to 15 seconds. ' |
db ' ' |
db ' Open SMTP server port 25 Close SMTP ' |
db 'x <- END MARKER, DONT DELETE ' |
irc_server_ip db 192,168,1,1 |
file_start dd 0x100000 |
files: |
dd 1,0,0,0x100000,0xd0000 |
db '/rd/1/smtps.txt',0 |
filel: |
dd 0,0,10000/512,0x100000,0xd0000 |
db '/rd/1/smtps.txt',0 |
server_active dd 0 |
status dd 0x0 |
header_sent db 0 |
channel_temp: times 100 db 0 |
channel_temp_length dd 0x0 |
close_connection dd 0x0 |
mail_rp dd 0 |
socket dd 0x0 |
bgc dd 0x000000 |
dd 0x000000 |
dd 0x00ff00 |
dd 0x0000ff |
dd 0x005500 |
dd 0xff00ff |
dd 0x00ffff |
dd 0x770077 |
tc dd 0xffffff |
dd 0xff00ff |
dd 0xffffff |
dd 0xffffff |
dd 0xffffff |
dd 0xffffff |
dd 0xffffff |
dd 0xffffff |
cursor_on_off dd 0x0 |
max_windows dd 20 |
thread_stack dd 0x9fff0 |
thread_nro dd 1 |
thread_screen dd I_END+120*80*1 |
action_header_blue db 10,'*** ',0 |
action_header_red db 10,'*** ',0 |
action_header_short db 10,'* ',0 |
posx dd 0x0 |
incoming_pos dd 0x0 |
incoming_string: times 128 db 0 |
pos dd 0x0 |
text_start dd I_END |
irc_data dd 0x0 |
print db 0x0 |
cmd dd 0x0 |
rxs dd 56 |
res: db 0,0 |
command: times 256 db 0x0 |
nick dd 0,0,0 |
irc_command dd 0,0 |
command_position dd 0x0 |
counter dd 0 |
send_to_server db 0 |
channel_list: times 32*20 db 32 |
send_to_channel dd 0x0 |
send_string: times 100 db 0x0 |
xpos dd 0 |
attribute dd 0 |
scroll dd 1 |
dd 8 |
numtext db ' ' |
wcolor dd 0x000000 |
labelt db 'Tiny SMTP email server v ',version |
labellen: |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/stackcfg/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm stackcfg.asm stackcfg |
@pause |
/programs/network/stackcfg/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm stackcfg.asm stackcfg |
@pause |
/programs/network/stackcfg/trunk/stackcfg.asm |
---|
0,0 → 1,704 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; ; |
; Stack Configuration Tool ; |
; ; |
; Compile with FASM for Menuet ; |
; ; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; start of code |
dd I_END ; size of image |
dd 0x100000 ; memory for app |
dd 0x7fff0 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Icon |
include 'lang.inc' |
START: ; start of execution |
call draw_window ; at first, draw the 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 |
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 |
shr eax,8 |
cmp eax,1 ; button id=1 ? |
jne noclose |
mov eax,-1 ; close this program |
int 0x40 |
noclose: |
cmp eax,2 |
je read_stack_setup |
cmp eax,3 |
je apply_stack_setup |
cmp eax,11 |
jb no_set_interface |
cmp eax,14 |
jg no_set_interface |
sub eax,11 |
mov [interface],eax |
call draw_window |
jmp still |
no_set_interface: |
cmp eax,21 |
jb no_ip_sf |
cmp eax,22 |
jg no_ip_sf |
sub eax,21 |
not eax |
and eax,1 |
mov [assigned],eax |
call draw_window |
jmp still |
no_ip_sf: |
cmp eax,7 ; GET IP |
jne no_read_ip |
mov [string_x],205 |
mov [string_y],80 |
mov [string_length],15 |
call read_string |
mov esi,string-1 |
mov edi,ip_address |
xor eax,eax |
ip1: |
inc esi |
cmp [esi],byte '0' |
jb ip2 |
cmp [esi],byte '9' |
jg ip2 |
imul eax,10 |
movzx ebx,byte [esi] |
sub ebx,48 |
add eax,ebx |
jmp ip1 |
ip2: |
mov [edi],al |
xor eax,eax |
inc edi |
cmp edi,ip_address+3 |
jbe ip1 |
call draw_window |
jmp still |
no_read_ip: |
cmp eax,5 ; GET COM PORT |
jne no_read_comport |
mov [string_x],272 |
mov [string_y],40 |
mov [string_length],3 |
call read_string |
movzx eax,byte [string] |
cmp eax,'A' |
jb gcp1 |
sub eax,'A'-'9'-1 |
gcp1: |
sub eax,48 |
shl eax,8 |
mov ebx,eax |
movzx eax,byte [string+1] |
cmp eax,'A' |
jb gcp2 |
sub eax,'A'-'9'-1 |
gcp2: |
sub eax,48 |
shl eax,4 |
add ebx,eax |
movzx eax,byte [string+2] |
cmp eax,'A' |
jb gcp3 |
sub eax,'A'-'9'-1 |
gcp3: |
sub eax,48 |
add ebx,eax |
mov [com_add],ebx |
call draw_window |
jmp still |
no_read_comport: |
cmp eax,6 ; GET COM IRQ |
jne no_read_comirq |
mov [string_x],284 |
mov [string_y],50 |
mov [string_length],1 |
call read_string |
movzx eax,byte [string] |
cmp eax,'A' |
jb gci1 |
sub eax,'A'-'9'-1 |
gci1: |
sub eax,48 |
mov [com_irq],eax |
call draw_window |
jmp still |
no_read_comirq: |
cmp eax, 8 ; set gateway ip |
jne no_set_gateway |
mov [string_x],205 |
mov [string_y],90 |
mov [string_length],15 |
call read_string |
mov esi,string-1 |
mov edi,gateway_ip |
xor eax,eax |
gip1: |
inc esi |
cmp [esi],byte '0' |
jb gip2 |
cmp [esi],byte '9' |
jg gip2 |
imul eax,10 |
movzx ebx,byte [esi] |
sub ebx,48 |
add eax,ebx |
jmp gip1 |
gip2: |
mov [edi],al |
xor eax,eax |
inc edi |
cmp edi,gateway_ip+3 |
jbe gip1 |
call draw_window |
jmp still |
no_set_gateway: |
cmp eax, 9 |
jne no_set_subnet |
mov [string_x],205 |
mov [string_y],100 |
mov [string_length],15 |
call read_string |
mov esi,string-1 |
mov edi,subnet_mask |
xor eax,eax |
sip1: |
inc esi |
cmp [esi],byte '0' |
jb sip2 |
cmp [esi],byte '9' |
jg sip2 |
imul eax,10 |
movzx ebx,byte [esi] |
sub ebx,48 |
add eax,ebx |
jmp sip1 |
sip2: |
mov [edi],al |
xor eax,eax |
inc edi |
cmp edi,subnet_mask+3 |
jbe sip1 |
call draw_window |
jmp still |
no_set_subnet: |
cmp eax, 10 |
jne no_set_dns |
mov [string_x],205 |
mov [string_y],110 |
mov [string_length],15 |
call read_string |
mov esi,string-1 |
mov edi,dns_ip |
xor eax,eax |
dip1: |
inc esi |
cmp [esi],byte '0' |
jb dip2 |
cmp [esi],byte '9' |
jg dip2 |
imul eax,10 |
movzx ebx,byte [esi] |
sub ebx,48 |
add eax,ebx |
jmp dip1 |
dip2: |
mov [edi],al |
xor eax,eax |
inc edi |
cmp edi,dns_ip+3 |
jbe dip1 |
call draw_window |
jmp still |
no_set_dns: |
jmp still |
read_stack_setup: |
mov eax,52 |
mov ebx,0 |
int 0x40 |
mov [config],eax |
mov eax,52 |
mov ebx,1 |
int 0x40 |
mov dword [ip_address],eax |
mov eax,52 |
mov ebx,9 |
int 0x40 |
mov dword [gateway_ip],eax |
mov eax,52 |
mov ebx,10 |
int 0x40 |
mov dword [subnet_mask],eax |
mov eax,52 |
mov ebx,13 |
int 0x40 |
mov dword [dns_ip],eax |
mov eax,[config] ; unwrap com IRQ |
shr eax,8 |
and eax,0xf |
mov [com_irq],eax |
mov eax,[config] ; unwrap com PORT |
shr eax,16 |
and eax,0xfff |
mov [com_add],eax |
mov eax,[config] ; unwrap IRQ |
and eax,0xf |
mov [interface],eax |
mov eax,[config] ; unwrap com PORT |
shr eax,7 |
and eax,1 |
mov [assigned],eax |
call draw_window |
jmp still |
apply_stack_setup: |
mov eax,[com_irq] |
shl eax,8 |
mov ebx,[com_add] |
shl ebx,16 |
add eax,ebx |
add eax,[interface] |
mov ebx,[assigned] |
shl ebx,7 |
add eax,ebx |
mov [config],eax |
mov eax,52 |
mov ebx,3 |
mov ecx,dword [ip_address] |
int 0x40 |
mov eax,52 |
mov ebx,11 |
mov ecx,dword [gateway_ip] |
int 0x40 |
mov eax,52 |
mov ebx,12 |
mov ecx,dword [subnet_mask] |
int 0x40 |
mov eax,52 |
mov ebx,14 |
mov ecx,dword [dns_ip] |
int 0x40 |
mov eax,52 |
mov ebx,2 |
mov ecx,[config] |
int 0x40 |
jmp still |
string_length dd 16 |
string_x dd 200 |
string_y dd 60 |
string db '________________' |
read_string: |
mov edi,string |
mov eax,'_' |
mov ecx,[string_length] |
cld |
rep stosb |
call print_text |
mov edi,string |
f11: |
mov eax,10 |
int 0x40 |
cmp eax,2 |
jne read_done |
mov eax,2 |
int 0x40 |
shr eax,8 |
cmp eax,13 |
je read_done |
cmp eax,8 |
jnz nobsl |
cmp edi,string |
jz f11 |
sub edi,1 |
mov [edi],byte '_' |
call print_text |
jmp f11 |
nobsl: |
cmp eax,dword 31 |
jbe f11 |
cmp eax,dword 95 |
jb keyok |
sub eax,32 |
keyok: |
mov [edi],al |
call print_text |
inc edi |
mov esi,string |
add esi,[string_length] |
cmp esi,edi |
jnz f11 |
read_done: |
call print_text |
ret |
print_text: |
pusha |
mov eax,13 |
mov ebx,[string_x] |
shl ebx,16 |
add ebx,[string_length] |
imul bx,6 |
mov ecx,[string_y] |
shl ecx,16 |
mov cx,8 |
mov edx,0xffffff |
int 0x40 |
mov eax,4 |
mov ebx,[string_x] |
shl ebx,16 |
add ebx,[string_y] |
mov ecx,0x000000 |
mov edx,string |
mov esi,[string_length] |
int 0x40 |
popa |
ret |
; ********************************************* |
; ******* 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+330 ; [x start] *65536 + [x size] |
mov ecx,100*65536+157 ; [y start] *65536 + [y size] |
mov edx,0x03ffffff ; color of work area RRGGBB,8->color gl |
mov esi,0x806688cc |
mov edi,0x006688cc |
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,0x00ddeeff ; color of text RRGGBB |
mov edx,labelt ; pointer to text beginning |
mov esi,labellen-labelt ; text length |
int 0x40 |
mov eax,8 ; BUTTON : CLOSE WINDOW |
mov ebx,(330-19)*65536+12 |
mov ecx,5*65536+12 |
mov edx,1 |
mov esi,[button_color] |
; int 0x40 |
mov eax,8 ; BUTTON : READ SETUP |
mov ebx,90*65536+65 |
mov ecx,127*65536+12 |
mov edx,2 |
int 0x40 |
mov eax,8 ; BUTTON : APPLY SETUP |
mov ebx,163*65536+65 |
mov ecx,127*65536+12 |
mov edx,3 |
int 0x40 |
mov eax,8 ; BUTTONS 11-14 : SELECT INTERFACE |
mov ebx,29*65536+8 |
mov ecx,39*65536+8 |
mov edx,11 |
interface_select: |
int 0x40 |
add ecx,10*65536 |
inc edx |
cmp edx,11+4 |
jb interface_select |
mov ebx,[interface] ; PRINT SELECTED INTERFACE 'X' |
imul ebx,10 |
add ebx,31*65536+39 |
mov eax,4 |
mov ecx,0xffffff |
mov edx,xx |
mov esi,1 |
int 0x40 |
mov eax,8 ; BUTTONS 21-22 : SERVER / MANUAL IP |
mov ebx,143*65536+8 |
mov ecx,69*65536+8 |
mov edx,21 |
mov esi,[button_color] |
int 0x40 |
mov eax,8 |
mov ebx,143*65536+8 |
mov ecx,79*65536+8 |
mov edx,22 |
int 0x40 |
mov ebx,[assigned] ; PRINT SELECTED SERVER/MANUAL 'X' |
not ebx |
and ebx,1 |
imul ebx,10 |
add ebx,145*65536+69 |
mov eax,4 |
mov ecx,0xffffff |
mov edx,xx |
mov esi,1 |
int 0x40 |
mov eax,47 ; COM ADDRESS |
mov ebx,3*65536+1*256 |
mov ecx,[com_add] |
mov edx,272*65536+40 |
mov esi,0x000000 |
int 0x40 |
mov eax,47 ; COM IRQ |
mov ebx,1*65536+1*256 |
mov ecx,[com_irq] |
mov edx,(266+3*6)*65536+50 |
mov esi,0x000000 |
int 0x40 |
mov edi,ip_address |
mov edx,205*65536+80 |
mov esi,0x000000 |
mov ebx,3*65536 |
ipdisplay: |
mov eax,47 |
movzx ecx,byte [edi] |
int 0x40 |
add edx,6*4*65536 |
inc edi |
cmp edi,ip_address+4 |
jb ipdisplay |
mov edi,gateway_ip |
mov edx,205*65536+90 |
mov esi,0x000000 |
mov ebx,3*65536 |
gipdisplay: |
mov eax,47 |
movzx ecx,byte [edi] |
int 0x40 |
add edx,6*4*65536 |
inc edi |
cmp edi,gateway_ip+4 |
jb gipdisplay |
mov edi,subnet_mask |
mov edx,205*65536+100 |
mov esi,0x000000 |
mov ebx,3*65536 |
sipdisplay: |
mov eax,47 |
movzx ecx,byte [edi] |
int 0x40 |
add edx,6*4*65536 |
inc edi |
cmp edi,subnet_mask+4 |
jb sipdisplay |
mov edi,dns_ip |
mov edx,205*65536+110 |
mov esi,0x000000 |
mov ebx,3*65536 |
dipdisplay: |
mov eax,47 |
movzx ecx,byte [edi] |
int 0x40 |
add edx,6*4*65536 |
inc edi |
cmp edi,dns_ip+4 |
jb dipdisplay |
mov eax,8 ; BUTTON 5 : SET PORT |
mov ebx,299*65536+8 |
mov ecx,39*65536+8 |
mov edx,5 |
mov esi,[button_color] |
int 0x40 |
mov eax,8 ; BUTTON 6 : SET IRQ |
mov ebx,299*65536+8 |
mov ecx,49*65536+8 |
mov edx,6 |
int 0x40 |
mov eax,8 ; BUTTON 7 : SET IP |
mov ebx,299*65536+8 |
mov ecx,79*65536+8 |
mov edx,7 |
int 0x40 |
mov eax,8 ; BUTTON 8 : SET gateway IP |
mov ebx,299*65536+8 |
mov ecx,89*65536+8 |
mov edx,8 |
int 0x40 |
mov eax,8 ; BUTTON 9 : SET subnet |
mov ebx,299*65536+8 |
mov ecx,99*65536+8 |
mov edx,9 |
int 0x40 |
mov eax,8 ; BUTTON 10 : SET dns ip |
mov ebx,299*65536+8 |
mov ecx,109*65536+8 |
mov edx,10 |
int 0x40 |
mov ebx,31*65536+40 ; draw info text with function 4 |
mov edx,text |
mov esi,49 |
newline: |
mov ecx,0x224466 |
cmp [edx],byte 'w' |
jne nowhite |
mov ecx,0xeeeeee |
nowhite: |
inc edx |
mov eax,4 |
int 0x40 |
add ebx,10 |
add edx,49 |
cmp [edx],byte 'x' |
jne newline |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
ret |
; DATA AREA |
text: |
db ' Not active Modem Com Port: 0x < ' |
db ' Slip Modem Com Irq: 0x < ' |
db ' PPP ' |
db ' Packet Driver IP server assigned ' |
db ' Fixed: . . . < ' |
db ' Gateway: . . . < ' |
db ' Subnet: . . . < ' |
db ' DNS IP: . . . < ' |
db ' ' |
db 'w READ APPLY ' |
xx: db 'x <- END MARKER, DONT DELETE ' |
button_color dd 0x2254b9 |
labelt: db 'STACK CONFIGURATION' |
labellen: |
ip_address db 000,000,000,000 |
gateway_ip db 000,000,000,000 |
subnet_mask db 000,000,000,000 |
dns_ip db 000,000,000,000 |
com_irq dd 0 ; irq for slip/ppp |
com_add dd 0 ; com port address for slip/ppp |
interface dd 0 ; not active,slip,ppp,packet driver |
assigned dd 1 ; get ip from server |
config dd 0 |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/stackinf/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm stackinf.asm stackinf |
@pause |
/programs/network/stackinf/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm stackinf.asm stackinf |
@pause |
/programs/network/stackinf/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 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/stackinf/trunk/stackinf.asm |
---|
0,0 → 1,158 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; |
;; ETHERNET SETUP |
;; |
use32 |
org 0x0 |
db 'MENUET00' ; 8 byte id |
dd 38 ; required os |
dd START ; program start |
dd I_END ; program image size |
dd 0x100000 ; required amount of memory |
dd 0x00000000 ; reserved=no extended header |
include 'lang.inc' |
include 'macros.inc' |
START: ; start of execution |
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 |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jnz noclose |
mov eax,-1 ; close this program |
int 0x40 |
noclose: |
cmp ah,2 |
jne no_details |
mov eax,19 |
mov ebx,file1 |
mov ecx,file2 |
int 0x40 |
jmp still |
no_details: |
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, 50*65536+370 ; [x start] *65536 + [x size] |
mov ecx,100*65536+230 ; [y start] *65536 + [y size] |
mov edx,0x03ffffff ; color of work area RRGGBB |
mov esi,0x80557799 ; color of grab bar RRGGBB,8->color glide |
mov edi,esi ; color of frames RRGGBB |
and edi,0xffffff |
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 |
; BUTTON |
mov eax,8 ; function 8 : define and draw button |
mov ebx,202*65536+135 ; [x start] *65536 + [x size] |
mov ecx,190*65536+16 ; [y start] *65536 + [y size] |
mov edx,2 ; button id |
mov esi,edi ; button color RRGGBB |
int 0x40 |
mov ebx,6*65536+35 ; draw info text with function 4 |
mov ecx,0;xffffff |
mov edx,text |
mov esi,60 |
newline: |
mov eax,4 |
int 0x40 |
add ebx,10 |
add edx,60 |
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 ' ETHERNET CONNECTION BETWEEN MENUET AND A TFTP SERVER ' |
db ' ' |
db ' 1) CURRENT ETHERNET CODE IS FOR RTL 8029 AND i8255x ' |
db ' BASED PCI CARDS ' |
db ' 2) START STACK CONFIG FROM NET MENU AND PRESS THE ' |
db ' READ BUTTON, ACTIVATE PACKET DRIVER, SET DESIRED ' |
db ' IP ADDRESS & APPLY ' |
db ' 3) SET THE SERVERS IP ADDRESS TO EG. 192.168.1.24 ' |
db ' ' |
db ' THE MENUET MACHINE SHOULD NOW BE ABLE TO RESPOND TO A ' |
db ' PING FROM THE SERVER, TRANSFER FILES USING TFTP AND USE ' |
db ' IRC CLIENT. SEE MENUET PAGES FOR MORE TCP/IP APPLICATIONS.' |
db ' ' |
db ' MOST LINUX DISTRIBUTIONS HAVE A TFTP SERVER INCLUDED ' |
db ' FOR MS YOU CAN DOWNLOAD TFTPD FROM TFTPD32.JOUNIN.NET ' |
db ' ' |
db ' DETAILED DESCRIPTION ' |
db 'x' |
file1: db 'TINYPAD ' |
file2: db 'STACK.TXT',0 |
labelt: |
db 'NETWORK INFO' |
labellen: |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/telnet/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm telnet.asm telnet |
@pause |
/programs/network/telnet/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm telnet.asm telnet |
@pause |
/programs/network/telnet/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 { ; mike.dld |
if ~a 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 |
} |
; language for programs |
lang fix ru ; ru en fr ge fi |
; 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 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/telnet/trunk/telnet.asm |
---|
0,0 → 1,818 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; |
; TERMINAL |
; |
; 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 0x100000 ; required amount of memory |
; esp = 0x7FFF0 |
dd 0x00000000 ; reserved=no extended header |
include 'lang.inc' |
include 'macros.inc' |
START: ; start of execution |
; Clear the screen memory |
mov eax, ' ' |
mov edi,text |
mov ecx,80*30 /4 |
cld |
rep stosd |
call draw_window |
still: |
; check connection status |
mov eax,53 |
mov ebx,6 |
mov ecx,[socket] |
int 0x40 |
mov ebx, [socket_status] |
mov [socket_status], eax |
cmp eax, ebx |
je waitev |
call draw_window |
waitev: |
mov eax,23 ; wait here for event |
mov ebx,20 |
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 |
; any data from the socket? |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socket] |
int 0x40 |
cmp eax, 0 |
jne read_input |
jmp still |
read_input: |
push ecx |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socket] |
int 0x40 |
pop ecx |
call handle_data |
push ecx |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socket] |
int 0x40 |
pop ecx |
cmp eax, 0 |
jne read_input |
call draw_text |
jmp still |
handle_data: |
; Telnet servers will want to negotiate options about our terminal window |
; just reject them all. |
; Telnet options start with the byte 0xff and are 3 bytes long. |
mov al, [telnetstate] |
cmp al, 0 |
je state0 |
cmp al, 1 |
je state1 |
cmp al, 2 |
je state2 |
jmp hd001 |
state0: |
cmp bl, 255 |
jne hd001 |
mov al, 1 |
mov [telnetstate], al |
ret |
state1: |
mov al, 2 |
mov [telnetstate], al |
ret |
state2: |
mov al, 0 |
mov [telnetstate], al |
mov [telnetrep+2], bl |
mov edx, 3 |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov esi, telnetrep |
int 0x40 |
ret |
hd001: |
cmp bl,13 ; BEGINNING OF LINE |
jne nobol |
mov ecx,[pos] |
add ecx,1 |
boll1: |
sub ecx,1 |
mov eax,ecx |
xor edx,edx |
mov ebx,80 |
div ebx |
cmp edx,0 |
jne boll1 |
mov [pos],ecx |
jmp newdata |
nobol: |
cmp bl,10 ; LINE DOWN |
jne nolf |
addx1: |
add [pos],dword 1 |
mov eax,[pos] |
xor edx,edx |
mov ecx,80 |
div ecx |
cmp edx,0 |
jnz addx1 |
mov eax,[pos] |
jmp cm1 |
nolf: |
cmp bl,8 ; BACKSPACE |
jne nobasp |
mov eax,[pos] |
dec eax |
mov [pos],eax |
mov [eax+text],byte 32 |
mov [eax+text+60*80],byte 0 |
jmp newdata |
nobasp: |
cmp bl,15 ; CHARACTER |
jbe newdata |
mov eax,[pos] |
mov [eax+text],bl |
mov eax,[pos] |
add eax,1 |
cm1: |
mov ebx,[scroll+4] |
imul ebx,80 |
cmp eax,ebx |
jb noeaxz |
mov esi,text+80 |
mov edi,text |
mov ecx,ebx |
cld |
rep movsb |
mov eax,ebx |
sub eax,80 |
noeaxz: |
mov [pos],eax |
newdata: |
ret |
red: ; REDRAW WINDOW |
call draw_window |
jmp still |
key: ; KEY |
mov eax,2 ; send to modem |
int 0x40 |
mov ebx, [socket_status] |
cmp ebx, 4 ; connection open? |
jne still ; no, so ignore key |
shr eax,8 |
cmp eax,178 ; ARROW KEYS |
jne noaup |
mov al,'A' |
call arrow |
jmp still |
noaup: |
cmp eax,177 |
jne noadown |
mov al,'B' |
call arrow |
jmp still |
noadown: |
cmp eax,179 |
jne noaright |
mov al,'C' |
call arrow |
jmp still |
noaright: |
cmp eax,176 |
jne noaleft |
mov al,'D' |
call arrow |
jmp still |
noaleft: |
modem_out: |
call to_modem |
jmp still |
button: ; BUTTON |
mov eax,17 |
int 0x40 |
cmp ah,1 ; CLOSE PROGRAM |
jne noclose |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
int 0x40 |
mov eax,-1 |
int 0x40 |
noclose: |
cmp ah, 2 ; Set IP |
jne notip |
mov [string_x], dword 78 |
mov [string_y], dword 276 |
mov [string_length], dword 15 |
call read_string |
mov esi,string-1 |
mov edi,ip_address |
xor eax,eax |
ip1: |
inc esi |
cmp [esi],byte '0' |
jb ip2 |
cmp [esi],byte '9' |
jg ip2 |
imul eax,10 |
movzx ebx,byte [esi] |
sub ebx,48 |
add eax,ebx |
jmp ip1 |
ip2: |
mov [edi],al |
xor eax,eax |
inc edi |
cmp edi,ip_address+3 |
jbe ip1 |
call draw_window |
jmp still |
notip: |
cmp ah, 3 ; set port |
jne notport |
mov [string_x], dword 215 |
mov [string_y], dword 276 |
mov [string_length], dword 4 |
call read_string |
mov esi,string-1 |
mov edi,port |
xor eax,eax |
ip11: |
inc esi |
cmp [esi],byte '0' |
jb ip21 |
cmp [esi],byte '9' |
jg ip21 |
imul eax,10 |
movzx ebx,byte [esi] |
sub ebx,48 |
add eax,ebx |
jmp ip11 |
ip21: |
mov [edi],al |
inc edi |
mov [edi],ah |
call draw_window |
jmp still |
notport: |
cmp ah, 4 ; connect |
jne notcon |
mov eax, [socket_status] |
cmp eax, 4 |
je still |
call connect |
jmp still |
notcon: |
cmp ah,5 ; disconnect |
jne notdiscon |
call disconnect |
jmp still |
notdiscon: ; Echo Toggle |
cmp ah, 6 |
jne still |
mov al, [echo] |
not al |
mov [echo], al |
call draw_window |
jmp still |
arrow: |
push eax |
mov al,27 |
call to_modem |
mov al,'[' |
call to_modem |
pop eax |
call to_modem |
ret |
to_modem: |
pusha |
push ax |
mov [tx_buff], al |
mov edx, 1 |
cmp al, 13 |
jne tm_000 |
mov edx, 2 |
tm_000: |
mov eax,53 |
mov ebx,7 |
mov ecx,[socket] |
mov esi, tx_buff |
int 0x40 |
pop bx |
mov al, [echo] |
cmp al, 0 |
je tm_001 |
push bx |
call handle_data |
pop bx |
cmp bl, 13 |
jne tm_002 |
mov bl, 10 |
call handle_data |
tm_002: |
call draw_text |
tm_001: |
popa |
ret |
disconnect: |
mov eax,53 |
mov ebx,8 |
mov ecx,[socket] |
int 0x40 |
ret |
connect: |
pusha |
mov ecx, 1000 ; local port starting at 1000 |
getlp: |
inc ecx |
push ecx |
mov eax, 53 |
mov ebx, 9 |
int 0x40 |
pop ecx |
cmp eax, 0 ; is this local port in use? |
jz getlp ; yes - so try next |
mov eax,53 |
mov ebx,5 |
mov dl, [ip_address + 3] |
shl edx, 8 |
mov dl, [ip_address + 2] |
shl edx, 8 |
mov dl, [ip_address + 1] |
shl edx, 8 |
mov dl, [ip_address] |
mov esi, edx |
movzx edx, word [port] ; telnet port id |
mov edi,1 ; active open |
int 0x40 |
mov [socket], eax |
popa |
ret |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
pusha |
mov eax,12 |
mov ebx,1 |
int 0x40 |
mov eax,0 ; DRAW WINDOW |
mov ebx,100*65536+491 + 8 +15 |
mov ecx,100*65536+270 + 20 ; 20 for status bar |
mov edx,[wcolor] |
add edx,0x02000000 |
mov esi,0x80557799 |
mov edi,0x00557799 |
int 0x40 |
mov eax,4 ; WINDOW LABEL |
mov ebx,8*65536+8 |
mov ecx,0x00ffffff |
mov edx,labelt |
mov esi,labellen-labelt |
int 0x40 |
mov eax,8 ; CLOSE BUTTON |
mov ebx,(491 + 20 -19)*65536+12 |
mov ecx,5*65536+12 |
mov edx,1 |
mov esi,0x557799 |
int 0x40 |
; draw status bar |
mov eax, 13 |
mov ebx, 4*65536+484 + 8 +15 |
mov ecx, 270*65536 + 3 |
mov edx, 0x00557799 |
int 0x40 |
mov eax,8 ; BUTTON 2: SET IP |
mov ebx,4*65536+70 |
mov ecx,273*65536+12 |
mov esi, 0x00557799 |
mov edx,2 |
int 0x40 |
mov eax,4 ; Button text |
mov ebx,6*65536+276 |
mov ecx,0x00ffffff |
mov edx,setipt |
mov esi,setiplen-setipt |
int 0x40 |
mov edi,ip_address ; display IP address |
mov edx,78*65536+276 |
mov esi,0x00ffffff |
mov ebx,3*65536 |
ipdisplay: |
mov eax,47 |
movzx ecx,byte [edi] |
int 0x40 |
add edx,6*4*65536 |
inc edi |
cmp edi,ip_address+4 |
jb ipdisplay |
mov eax,8 ; BUTTON 3: SET PORT |
mov ebx,173*65536+38 |
mov ecx,273*65536+12 |
mov edx,3 |
mov esi, 0x00557799 |
int 0x40 |
mov eax,4 ; Button text |
mov ebx,178*65536+276 |
mov ecx,0x00ffffff |
mov edx,setportt |
mov esi,setportlen-setportt |
int 0x40 |
mov edx,216*65536+276 ; display port |
mov esi,0x00ffffff |
mov ebx,4*65536 |
mov eax,47 |
movzx ecx,word [port] |
int 0x40 |
mov eax,8 ; BUTTON 4: Connect |
mov ebx,250*65536+50 |
mov ecx,273*65536+12 |
mov esi, 0x00557799 |
mov edx,4 |
int 0x40 |
mov eax,4 ; Button text |
mov ebx,255*65536+276 |
mov ecx,0x00ffffff |
mov edx,cont |
mov esi,conlen-cont |
int 0x40 |
mov eax,8 ; BUTTON 5: disconnect |
mov ebx,303*65536+70 |
mov ecx,273*65536+12 |
mov edx,5 |
mov esi, 0x00557799 |
int 0x40 |
mov eax,4 ; Button text |
mov ebx,307*65536+276 |
mov ecx,0x00ffffff |
mov edx,dist |
mov esi,dislen-dist |
int 0x40 |
mov esi,contlen-contt ; display connected status |
mov edx, contt |
mov eax, [socket_status] |
cmp eax, 4 ; 4 is connected |
je pcon |
mov esi,discontlen-discontt |
mov edx, discontt |
pcon: |
mov eax,4 ; status text |
mov ebx,380*65536+276 |
mov ecx,0x00ffffff |
int 0x40 |
mov eax,8 ; BUTTON 6: echo |
mov ebx,460*65536+50 |
mov ecx,273*65536+12 |
mov edx,6 |
mov esi, 0x00557799 |
int 0x40 |
mov edx,echot |
mov esi,echolen-echot |
mov al, [echo] |
cmp al, 0 |
jne peo |
mov edx,echoot |
mov esi,echoolen-echoot |
peo: |
mov eax,4 ; Button text |
mov ebx,463*65536+276 |
mov ecx,0x00ffffff |
int 0x40 |
xor eax,eax |
mov edi,text+80*30 |
mov ecx,80*30 /4 |
cld |
rep stosd |
call draw_text |
mov eax,12 |
mov ebx,2 |
int 0x40 |
popa |
ret |
draw_text: |
pusha |
mov esi,text |
mov eax,0 |
mov ebx,0 |
newletter: |
mov cl,[esi] |
cmp cl,[esi+30*80] |
jne yesletter |
jmp noletter |
yesletter: |
mov [esi+30*80],cl |
; erase character |
pusha |
mov edx, 0 ; bg colour |
mov ecx, ebx |
add ecx, 26 |
shl ecx, 16 |
mov cx, 9 |
mov ebx, eax |
add ebx, 6 |
shl ebx, 16 |
mov bx, 6 |
mov eax, 13 |
int 0x40 |
popa |
; draw character |
pusha |
mov ecx, 0x00ffffff |
push bx |
mov ebx,eax |
add ebx,6 |
shl ebx,16 |
pop bx |
add bx,26 |
mov eax,4 |
mov edx,esi |
mov esi,1 |
int 0x40 |
popa |
noletter: |
add esi,1 |
add eax,6 |
cmp eax,80*6 |
jb newletter |
mov eax,0 |
add ebx,10 |
cmp ebx,24*10 |
jb newletter |
popa |
ret |
read_string: |
mov edi,string |
mov eax,'_' |
mov ecx,[string_length] |
inc ecx |
cld |
rep stosb |
call print_text |
mov edi,string |
f11: |
mov eax,10 |
int 0x40 |
cmp eax,2 |
jne read_done |
mov eax,2 |
int 0x40 |
shr eax,8 |
cmp eax,13 |
je read_done |
cmp eax,8 |
jnz nobsl |
cmp edi,string |
jz f11 |
sub edi,1 |
mov [edi],byte '_' |
call print_text |
jmp f11 |
nobsl: |
cmp eax,dword 31 |
jbe f11 |
cmp eax,dword 95 |
jb keyok |
sub eax,32 |
keyok: |
mov [edi],al |
call print_text |
inc edi |
mov esi,string |
add esi,[string_length] |
cmp esi,edi |
jnz f11 |
read_done: |
call print_text |
ret |
print_text: |
pusha |
mov eax,13 |
mov ebx,[string_x] |
shl ebx,16 |
add ebx,[string_length] |
imul bx,6 |
mov ecx,[string_y] |
shl ecx,16 |
mov cx,8 |
mov edx,0x00000000 |
int 0x40 |
mov eax,4 |
mov ebx,[string_x] |
shl ebx,16 |
add ebx,[string_y] |
mov ecx,0x00ffffff |
mov edx,string |
mov esi,[string_length] |
int 0x40 |
popa |
ret |
; DATA AREA |
telnetrep db 0xff,0xfc,0x00 |
telnetstate db 0 |
string_length dd 16 |
string_x dd 200 |
string_y dd 60 |
string db '________________' |
tx_buff db 0, 10 |
ip_address db 001,002,003,004 |
port db 0,0 |
echo db 0 |
socket dd 0x0 |
socket_status dd 0x0 |
pos dd 80 * 1 |
scroll dd 1 |
dd 24 |
wcolor dd 0x000000 |
labelt db 'Telnet v0.1' |
labellen: |
setipt db 'IP Address: . . .' |
setiplen: |
setportt db 'Port:' |
setportlen: |
cont db 'Connect' |
conlen: |
dist db 'Disconnect' |
dislen: |
contt db 'Connected' |
contlen: |
discontt db 'Disconnected' |
discontlen: |
echot db 'Echo On' |
echolen: |
echoot db 'Echo Off' |
echoolen: |
text: |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/terminal/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm terminal.asm terminal |
@pause |
/programs/network/terminal/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm terminal.asm terminal |
@pause |
/programs/network/terminal/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 { ; mike.dld |
if ~a 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 |
} |
; language for programs |
lang fix ru ; ru en fr ge fi |
; 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 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/terminal/trunk/terminal.asm |
---|
0,0 → 1,764 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; |
; TERMINAL |
; |
; 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 0x100000 ; required amount of memory |
; esp = 0x7FFF0 |
dd 0x00000000 ; reserved=no extended header |
include 'lang.inc' |
include 'macros.inc' |
START: ; start of execution |
call draw_window |
call set_variables |
still: |
mov eax,23 ; wait here for event |
mov ebx,20 |
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 |
je read_input |
jmp still |
read_input: |
push ecx |
mov eax,42 |
mov ebx,4 |
int 0x40 |
pop ecx |
cmp bl,27 ; ESCAPE COMMAND |
jne no_esc |
call esc_command |
jmp newdata |
no_esc: |
cmp bl,13 ; BEGINNING OF LINE |
jne nobol |
mov ecx,[pos] |
add ecx,1 |
boll1: |
sub ecx,1 |
mov eax,ecx |
xor edx,edx |
mov ebx,80 |
div ebx |
cmp edx,0 |
jne boll1 |
mov [pos],ecx |
jmp newdata |
nobol: |
cmp bl,10 ; LINE DOWN |
jne nolf |
addx1: |
add [pos],dword 1 |
mov eax,[pos] |
xor edx,edx |
mov ecx,80 |
div ecx |
cmp edx,0 |
jnz addx1 |
mov eax,[pos] |
jmp cm1 |
nolf: |
cmp bl,8 ; BACKSPACE |
jne nobasp |
mov eax,[pos] |
dec eax |
mov [pos],eax |
mov [eax+text],byte 32 |
mov [eax+text+60*80],byte 0 |
jmp newdata |
nobasp: |
cmp bl,15 ; CHARACTER |
jbe newdata |
mov eax,[pos] |
call draw_data |
mov eax,[pos] |
add eax,1 |
cm1: |
mov ebx,[scroll+4] |
imul ebx,80 |
cmp eax,ebx |
jb noeaxz |
mov esi,text+80 |
mov edi,text |
mov ecx,ebx |
cld |
rep movsb |
mov esi,text+80+60*80 |
mov edi,text+60*80 |
mov ecx,ebx |
cld |
rep movsb |
mov eax,ebx |
sub eax,80 |
noeaxz: |
mov [pos],eax |
newdata: |
mov eax,11 |
int 0x40 |
cmp eax,16+4 |
je read_input |
call draw_text |
jmp still |
red: ; REDRAW WINDOW |
call draw_window |
jmp still |
key: ; KEY |
mov eax,2 ; send to modem |
int 0x40 |
shr eax,8 |
cmp eax,178 ; ARROW KEYS |
jne noaup |
mov al,'A' |
call arrow |
jmp still |
noaup: |
cmp eax,177 |
jne noadown |
mov al,'B' |
call arrow |
jmp still |
noadown: |
cmp eax,179 |
jne noaright |
mov al,'C' |
call arrow |
jmp still |
noaright: |
cmp eax,176 |
jne noaleft |
mov al,'D' |
call arrow |
jmp still |
noaleft: |
modem_out: |
mov ecx,0x3f8 |
mov bl,al |
mov eax,43 |
int 0x40 |
jmp still |
button: ; BUTTON |
mov eax,17 |
int 0x40 |
cmp ah,1 ; CLOSE PROGRAM |
jne noclose |
mov eax,45 ; FREE IRQ |
mov ebx,1 |
mov ecx,4 |
int 0x40 |
mov eax,46 |
mov ebx,1 |
mov ecx,0x3f0 |
mov edx,0x3ff |
int 0x40 |
mov eax,-1 |
int 0x40 |
noclose: |
jmp still |
arrow: |
push eax |
mov al,27 |
call to_modem |
mov al,'[' |
call to_modem |
pop eax |
call to_modem |
ret |
to_modem: |
pusha |
mov ecx,0x3f8 |
mov ebx,eax |
mov eax,43 |
int 0x40 |
mov eax,5 |
mov ebx,5 |
int 0x40 |
popa |
ret |
draw_data: |
pusha |
cmp bl,0xe4 ; Á |
jne noe4 |
mov bl,0xc1 |
noe4: |
cmp bl,0xc4 ; É |
jne noc4 |
mov bl,0xc9 |
noc4: |
mov [eax+text],bl |
mov bl,byte [attribute] |
mov [eax+text+60*80],bl |
popa |
ret |
irqtable: |
dd 0x3f8 + 0x01000000 ; read port 0x3f8, byte |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
set_variables: |
pusha |
mov eax,46 |
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 |
mov ebx,irqtable |
mov ecx,4 |
int 0x40 |
; jmp noportint |
mov cx,0x3f8+3 |
mov bl,0x80 |
mov eax,43 |
int 0x40 |
mov cx,0x3f8+1 |
mov bl,0 |
mov eax,43 |
int 0x40 |
mov cx,0x3f8+0 |
mov bl,0x30 / 16 |
mov eax,43 |
int 0x40 |
mov cx,0x3f8+3 |
mov bl,3 |
mov eax,43 |
int 0x40 |
mov cx,0x3f8+4 |
mov bl,0xB |
mov eax,43 |
int 0x40 |
mov cx,0x3f8+1 |
mov bl,1 |
mov eax,43 |
int 0x40 |
noportint: |
mov eax,40 |
mov ebx,0000000000010000b shl 16 + 111b |
int 0x40 |
popa |
ret |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
pusha |
mov eax,12 |
mov ebx,1 |
int 0x40 |
mov eax,0 ; DRAW WINDOW |
mov ebx,100*65536+491 |
mov ecx,100*65536+270 |
mov edx,[wcolor] |
add edx,0x02000000 |
mov esi,0x80557799 |
mov edi,0x00557799 |
int 0x40 |
mov eax,4 ; WINDOW LABEL |
mov ebx,8*65536+8 |
mov ecx,0x00ffffff |
mov edx,labelt |
mov esi,labellen-labelt |
int 0x40 |
mov eax,8 ; CLOSE BUTTON |
mov ebx,(491-19)*65536+12 |
mov ecx,5*65536+12 |
mov edx,1 |
mov esi,0x557799 |
int 0x40 |
xor eax,eax |
mov edi,text+80*30 |
mov ecx,80*30 /4 |
cld |
rep stosd |
call draw_text |
mov eax,12 |
mov ebx,2 |
int 0x40 |
popa |
ret |
bgc dd 0x000000 |
dd 0x000000 |
dd 0x00ff00 |
dd 0x0000ff |
dd 0x005500 |
dd 0xff00ff |
dd 0x00ffff |
dd 0x770077 |
tc dd 0xffffff |
dd 0xff00ff |
dd 0xffffff |
dd 0xffffff |
dd 0xffffff |
dd 0xffffff |
dd 0xffffff |
dd 0xffffff |
draw_text: |
pusha |
mov esi,text |
mov eax,0 |
mov ebx,0 |
newletter: |
mov cl,[esi] |
mov dl,[esi+60*80] |
cmp cl,[esi+30*80] |
jne yesletter |
cmp dl,[esi+90*80] |
jne yesletter |
jmp noletter |
yesletter: |
mov [esi+30*80],cl |
mov [esi+90*80],dl |
pusha |
and edx,0xff |
shl edx,2 |
add edx,bgc |
mov edx,[edx] |
mov ecx,ebx |
add ecx,26 |
shl ecx,16 |
mov cx,9 |
mov ebx,eax |
add ebx,6 |
shl ebx,16 |
mov bx,6 |
mov eax,13 |
int 0x40 |
popa |
pusha |
and edx,0xff |
shl edx,2 |
add edx,tc |
mov ecx,[edx] |
push bx |
mov ebx,eax |
add ebx,6 |
shl ebx,16 |
pop bx |
add bx,26 |
mov eax,4 |
mov edx,esi |
mov esi,1 |
int 0x40 |
popa |
noletter: |
add esi,1 |
add eax,6 |
cmp eax,80*6 |
jb newletter |
mov eax,0 |
add ebx,10 |
cmp ebx,24*10 |
jb newletter |
popa |
ret |
esc_command: |
mov eax,32 |
mov edi,esccmd |
mov ecx,10 |
cld |
rep stosb |
mov edi,esccmd |
newescc: |
mov eax,42 |
mov ebx,4 |
int 0x40 |
cmp ecx,0 |
je escok |
mov eax,5 |
mov ebx,1 |
int 0x40 |
jmp newescc |
escok: |
mov [edi],bl |
add edi,1 |
cmp edi,esccmd+20 |
je dontunderstand |
mov esi,escend |
nec: |
cmp bl,[esi] |
jz com_ok |
add esi,1 |
cmp [esi],byte 0 |
je newescc |
jmp nec |
com_ok: |
call get_numbers |
cmp bl,'H' ; SET CURSOR POSITION |
jne no_cursor_position |
cmp [escnumbers],0 |
jne ncp1 |
mov [pos],dword 0 |
jmp cmd_done |
ncp1: |
mov eax,[escnumbers] |
dec eax |
imul eax,80 |
add eax,[escnumbers+4] |
dec eax |
mov [pos],eax |
jmp cmd_done |
no_cursor_position: |
cmp bl,'K' ; ERASE LINE |
jne no_erase_end_of_line |
cmp [escnumbers],0 |
jne no_end_line |
mov ecx,[pos] |
eeol: |
mov [ecx+text],byte ' ' |
mov [ecx+text+60*80],byte 0 |
add ecx,1 |
xor edx,edx |
mov eax,ecx |
mov ebx,80 |
div ebx |
cmp edx,0 |
jne eeol |
jmp cmd_done |
no_end_line: |
cmp [escnumbers],1 ; BEGINNING OF LINE |
jne no_beg_line |
mov ecx,[pos] |
ebol: |
mov [ecx+text],byte ' ' |
mov [ecx+text+60*80],byte 0 |
sub ecx,1 |
xor edx,edx |
mov eax,ecx |
mov ebx,80 |
div ebx |
cmp edx,0 |
jne ebol |
mov [pos],ecx |
jmp cmd_done |
no_beg_line: |
no_erase_end_of_line: |
cmp bl,'J' ; ERASE TO END OF SCREEN |
jne no_erase_to_end_of_screen |
cmp [escnumbers],dword 0 |
jne no_erase_to_end_of_screen |
mov ecx,[pos] |
eteos: |
mov [ecx+text],byte ' ' |
mov [ecx+text+60*80],byte 0 |
add ecx,1 |
cmp ecx,80*24+1 |
jb eteos |
jmp cmd_done |
no_erase_to_end_of_screen: |
cmp bl,'r' ; SET SCROLL REGION |
jne no_scroll_region |
mov eax,[escnumbers] |
dec eax |
mov [scroll+0],eax |
mov eax,[escnumbers+4] |
mov [scroll+4],eax |
jmp cmd_done |
no_scroll_region: |
cmp bl,'A' ; CURSOR UP |
jne no_cursor_up |
mov eax,[pos] |
sub eax,80 |
mov [pos],eax |
jmp cmd_done |
no_cursor_up: |
cmp bl,'C' ; CURSOR LEFT |
jne no_cursor_left |
mov eax,[pos] |
mov ebx,[escnumbers] |
sub eax,ebx |
mov [pos],eax |
call cmd_done |
no_cursor_left: |
cmp bl,'m' ; CHARACTER ATTRIBUTE |
jne no_char_attribute |
mov eax,[escnumbers] |
mov [attribute],eax |
jmp cmd_done |
no_char_attribute: |
cmp bl,'Z' ; TERMINAL TYPE |
jne no_terminal_type |
mov al,27 |
call to_modem |
mov al,'?' |
call to_modem |
mov al,'1' |
call to_modem |
mov al,';' |
call to_modem |
mov al,'0' |
call to_modem |
mov al,'c' |
call to_modem |
jmp cmd_done |
no_terminal_type: |
dontunderstand: |
cmd_done: |
ret |
draw_numbers: |
pusha |
mov eax,13 |
mov ebx,250*65536+100 |
mov ecx,8*65536+8 |
mov edx,0x000000 |
int 0x40 |
mov eax,[escnumbers] |
xor edx,edx |
mov ebx,10 |
div ebx |
add eax,48 |
add edx,48 |
mov byte [numtext+0],al |
mov byte [numtext+1],dl |
mov eax,[escnumbers+4] |
xor edx,edx |
mov ebx,10 |
div ebx |
add eax,48 |
add edx,48 |
mov [numtext+3],al |
mov [numtext+4],dl |
mov eax,4 |
mov ebx,250*65536+8 |
mov ecx,0xffffff |
mov edx,numtext |
mov esi,10 |
int 0x40 |
popa |
ret |
draw_event: |
pusha |
mov eax,13 |
mov ebx,150*65536+100 |
mov ecx,8*65536+8 |
mov edx,0xffffff |
int 0x40 |
mov eax,4 |
mov ebx,150*65536+8 |
mov ecx,0x000000 |
mov edx,esccmd |
mov esi,20 |
int 0x40 |
popa |
ret |
get_numbers: |
pusha |
mov [escnumbers+0],0 |
mov [escnumbers+4],0 |
mov [escnumbers+8],0 |
mov ecx,esccmd |
cmp [ecx+1],byte '0' |
jb gn_over |
cmp [ecx+1],byte '9' |
jg gn_over |
mov edi,escnumbers |
gn_new: |
add ecx,1 |
movzx eax,byte [ecx] |
sub eax,48 |
add ecx,1 |
cmp [ecx],byte '0' |
jb gnl1 |
cmp [ecx],byte '9' |
jg gnl1 |
mov ebx,10 |
xor edx,edx |
mul ebx |
movzx ebx,byte[ecx] |
add eax,ebx |
sub eax,48 |
add ecx,1 |
gnl1: |
mov [edi],eax |
add edi,4 |
cmp [ecx],byte ';' |
je gn_new |
gn_over: |
popa |
ret |
; DATA AREA |
pos dd 80*10 |
irc_data dd 0x0 |
print db 0x0 |
attribute dd 0 |
scroll dd 1 |
dd 24 |
numtext db ' ' |
esccmd dd 0,0,0,0,0,0,0,0,0,0,0,0,0 |
escend db 'ZrhlABCDHfDME=>NmKJgincoyq',0 |
escnumbers dd 0,0,0,0,0 |
wcolor dd 0x000000 |
labelt db 'TERMINAL FOR MODEM IN COM1 0.03' |
labellen: |
text: |
db ' ' |
db ' ' |
db '*** A TELNET APPLICATION FOR HAYES COMPATIBLE MODEMS IN COM1 ' |
db ' ' |
db '*** USE HAYES COMMANDS TO CONNECT TO A SERVER ' |
db ' ' |
db '*** ATDT (PHONENUMBER) ' |
db ' ' |
db ' ' |
db ' ' |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/tftpa/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm tftpa.asm tftpa |
@pause |
/programs/network/tftpa/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm tftpa.asm tftpa |
@pause |
/programs/network/tftpa/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 { ; mike.dld |
if ~a 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 |
} |
; language for programs |
lang fix ru ; ru en fr ge fi |
; 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 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/tftpa/trunk/tftpa.asm |
---|
0,0 → 1,755 |
; |
; TFTP Wave Player |
; |
; Compile with FASM for Menuet |
; |
; |
; 12.7.2002 - Audio system calls by VT |
; |
use32 |
org 0x0 |
db 'MENUET00' ; 8 byte id |
dd 38 ; required os |
dd START ; program start |
dd I_END ; program image size |
dd 0x100000 ; required amount of memory |
dd 0x00000000 ; reserved=no extended header |
include 'lang.inc' |
include 'macros.inc' |
delay dd 145 |
wait_for dd 0x0 |
START: ; start of execution |
mov dword [prompt], p9 |
mov dword [promptlen], p9len - p9 |
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: ; Keys are not valid at this part of the |
mov eax,2 ; loop. 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 noclose |
; close socket before exiting |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
int 0x40 |
mov [socketNum], dword 0 |
mov eax,0xffffffff ; close this program |
int 0x40 |
noclose: |
cmp ah,2 ; copy file to local machine? |
jnz nocopyl |
mov dword [prompt], p5 |
mov dword [promptlen], p5len - p5 |
call draw_window ; |
; Copy File from Remote Host to this machine |
call translateData ; Convert Filename & IP address |
mov edi, tftp_filename + 1 |
mov [edi], byte 0x01 ; setup tftp msg |
call copyFromRemote |
jmp still |
nocopyl: |
cmp ah,4 |
jz f1 |
cmp ah,5 |
jz f2 |
jmp nof12 |
f1: |
mov [addr],dword source |
mov [ya],dword 35 |
jmp rk |
f2: |
mov [addr],dword destination |
mov [ya],dword 35+16 |
rk: |
mov ecx,15 |
mov edi,[addr] |
mov al,' ' |
rep stosb |
call print_text |
mov edi,[addr] |
f11: |
mov eax,10 |
int 0x40 |
cmp eax,2 |
jz fbu |
jmp still |
fbu: |
mov eax,2 |
int 0x40 ; get key |
shr eax,8 |
cmp eax,8 |
jnz nobs |
cmp edi,[addr] |
jz f11 |
sub edi,1 |
mov [edi],byte ' ' |
call print_text |
jmp f11 |
nobs: |
cmp eax,dword 31 |
jbe f11 |
cmp eax,dword 95 |
jb keyok |
sub eax,32 |
keyok: |
mov [edi],al |
call print_text |
add edi,1 |
mov esi,[addr] |
add esi,15 |
cmp esi,edi |
jnz f11 |
jmp still |
print_text: |
mov eax,13 |
mov ebx,103*65536+15*6 |
mov ecx,[ya] |
shl ecx,16 |
mov cx,8 |
mov edx,0x224466 |
int 0x40 |
mov eax,4 |
mov ebx,103*65536 |
add ebx,[ya] |
mov ecx,0xffffff |
mov edx,[addr] |
mov esi,15 |
int 0x40 |
ret |
nof12: |
jmp still |
;*************************************************************************** |
; Function |
; translateData |
; |
; Description |
; Coverts the filename and IP address typed in by the user into |
; a format suitable for the IP layer. |
; |
; The filename, in source, is converted and stored in tftp_filename |
; The host ip, in destination, is converted and stored in tftp_IP |
; |
;*************************************************************************** |
translateData: |
; first, build up the tftp command string. This includes the filename |
; and the transfer protocol |
; First, write 0,0 |
mov al, 0 |
mov edi, tftp_filename |
mov [edi], al |
inc edi |
mov [edi], al |
inc edi |
; Now, write the file name itself, and null terminate it |
mov ecx, 15 |
mov ah, ' ' |
mov esi, source |
td001: |
lodsb |
stosb |
cmp al, ah |
loopnz td001 |
cmp al,ah ; Was the entire buffer full of characters? |
jne td002 |
dec edi ; No - so remove ' ' character |
td002: |
mov [edi], byte 0 |
inc edi |
mov [edi], byte 'O' |
inc edi |
mov [edi], byte 'C' |
inc edi |
mov [edi], byte 'T' |
inc edi |
mov [edi], byte 'E' |
inc edi |
mov [edi], byte 'T' |
inc edi |
mov [edi], byte 0 |
mov esi, tftp_filename |
sub edi, esi |
mov [tftp_len], edi |
; Now, convert the typed IP address into a real address |
; No validation is done on the number entered |
; ip addresses must be typed in normally, eg |
; 192.1.45.24 |
xor eax, eax |
mov dh, 10 |
mov dl, al |
mov [tftp_IP], eax |
; 192.168.24.1 1.1.1.1 1. 9.2.3. |
mov esi, destination |
mov edi, tftp_IP |
mov ecx, 4 |
td003: |
lodsb |
sub al, '0' |
add dl, al |
lodsb |
cmp al, '.' |
je ipNext |
cmp al, ' ' |
je ipNext |
mov dh, al |
sub dh, '0' |
mov al, 10 |
mul dl |
add al, dh |
mov dl, al |
lodsb |
cmp al, '.' |
je ipNext |
cmp al, ' ' |
je ipNext |
mov dh, al |
sub dh, '0' |
mov al, 10 |
mul dl |
add al, dh |
mov dl, al |
lodsb |
ipNext: |
mov [edi], dl |
inc edi |
mov dl, 0 |
loop td003 |
ret |
;*************************************************************************** |
; Function |
; copyFromRemote |
; |
; Description |
; |
;*************************************************************************** |
copyFromRemote: |
mov eax,0x20000-512 |
mov [fileposition], eax |
; Get a random # for the local socket port # |
mov eax, 3 |
int 0x40 |
mov ecx, eax |
shr ecx, 8 ; Set up the local port # with a random # |
; open socket |
mov eax, 53 |
mov ebx, 0 |
mov edx, 69 ; remote port |
mov esi, [tftp_IP] ; remote IP ( in intenet format ) |
int 0x40 |
mov [socketNum], eax |
; make sure there is no data in the socket - there shouldn't be.. |
cfr001: |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
int 0x40 ; any more data? |
cmp eax, 0 |
jne cfr001 ; yes, so get it |
; Now, request the file |
mov eax, 53 |
mov ebx, 4 |
mov ecx, [socketNum] |
mov edx, [tftp_len] |
mov esi, tftp_filename |
int 0x40 |
cfr002: |
mov eax,23 ; wait here for event |
mov ebx,1 ; Time out after 10ms |
int 0x40 |
cmp eax,1 ; redraw request ? |
je cfr003 |
cmp eax,2 ; key in buffer ? |
je cfr004 |
cmp eax,3 ; button in buffer ? |
je cfr005 |
; Any data to fetch? |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
int 0x40 |
cmp eax, 0 |
je cfr002 |
push eax ; eax holds # chars |
; Update the text on the display - once |
mov eax, [prompt] |
cmp eax, p3 |
je cfr008 |
mov dword [prompt], p3 |
mov dword [promptlen], p3len - p3 |
call draw_window ; |
cfr008: |
; we have data - this will be a tftp frame |
; read first two bytes - opcode |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte |
pop eax |
; bl holds tftp opcode. Can only be 3 (data) or 5 ( error ) |
cmp bl, 3 |
jne cfrerr |
push eax |
; do data stuff. Read block #. Read data. Send Ack. |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte |
mov [blockNumber], bl |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte |
mov [blockNumber+1], bl |
cfr007: |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte |
mov esi, [fileposition] |
mov [esi], bl |
mov [esi+1],bl |
add dword [fileposition],2 |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
int 0x40 ; any more data? |
cmp eax, 0 |
jne cfr007 ; yes, so get it |
cmp [fileposition],0x20000+0xffff |
jb get_more_stream |
wait_more: |
mov eax,5 ; wait for correct timer position |
; to trigger new play block |
mov ebx,1 |
int 0x40 |
mov eax,26 |
mov ebx,9 |
int 0x40 |
cmp eax,[wait_for] |
jb wait_more |
add eax,[delay] |
mov [wait_for],eax |
mov esi,0x20000 |
mov edi,0x10000 |
mov ecx,65536 |
cld |
rep movsb |
mov eax,55 |
mov ebx,0 |
mov ecx,0x10000 |
int 0x40 |
mov eax,55 |
mov ebx,1 |
int 0x40 |
mov [fileposition],0x20000 |
get_more_stream: |
; write the block number into the ack |
mov al, [blockNumber] |
mov [ack + 2], al |
mov al, [blockNumber+1] |
mov [ack + 3], al |
; send an 'ack' |
mov eax, 53 |
mov ebx, 4 |
mov ecx, [socketNum] |
mov edx, ackLen - ack |
mov esi, ack |
int 0x40 |
; If # of chars in the frame is less that 516, |
; this frame is the last |
pop eax |
cmp eax, 516 |
je cfr002 |
; Write the file |
mov eax, 33 |
mov ebx, source |
mov edx, [filesize] |
mov ecx, I_END + 512 |
mov esi, 0 |
int 0x40 |
jmp cfrexit |
cfrerr: |
; simple implementation on error - just read all data, and return |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
int 0x40 ; any more data? |
cmp eax, 0 |
jne cfrerr ; yes, so get it |
jmp cfr006 ; close socket and close app |
cfr003: ; redraw request |
call draw_window |
jmp cfr002 |
cfr004: ; key pressed |
mov eax,2 ; just read it and ignore |
int 0x40 |
jmp cfr002 |
cfr005: ; button |
mov eax,17 ; get id |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jne cfr002 ; If not, ignore. |
cfr006: |
; close socket |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
int 0x40 |
mov [socketNum], dword 0 |
mov eax,-1 ; close this program |
int 0x40 |
jmp $ |
cfrexit: |
; close socket |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
int 0x40 |
mov [socketNum], dword 0 |
mov dword [prompt], p4 |
mov dword [promptlen], p4len - p4 |
call draw_window ; |
ret |
; ********************************************* |
; ******* 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,100*65536+170 ; [y start] *65536 + [y size] |
mov edx,0x03224466 ; color of work area RRGGBB |
mov esi,0x00334455 ; color of grab bar RRGGBB,8->color gl |
mov edi,0x00ddeeff ; 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,labelt ; pointer to text beginning |
mov esi,labellen-labelt ; text length |
int 0x40 |
mov eax,8 ; COPY BUTTON |
mov ebx,20*65536+190 |
mov ecx,79*65536+15 |
mov edx,3 |
mov esi,0x557799 |
; int 0x40 |
mov eax,8 ; DELETE BUTTON |
mov ebx,20*65536+190 |
mov ecx,111*65536+15 |
mov edx,2 |
mov esi,0x557799 |
int 0x40 |
mov eax,8 |
mov ebx,200*65536+10 |
mov ecx,34*65536+10 |
mov edx,4 |
mov esi,0x557799 |
int 0x40 |
mov eax,8 |
mov ebx,200*65536+10 |
mov ecx,50*65536+10 |
mov edx,5 |
mov esi,0x557799 |
int 0x40 |
; Copy the file name to the screen buffer |
; file name is same length as IP address, to |
; make the math easier later. |
cld |
mov esi,source |
mov edi,text+13 |
mov ecx,15 |
rep movsb |
; copy the IP address to the screen buffer |
mov esi,destination |
mov edi,text+40+13 |
mov ecx,15 |
rep movsb |
; copy the prompt to the screen buffer |
mov esi,[prompt] |
mov edi,text+280 |
mov ecx,[promptlen] |
rep movsb |
; Re-draw the screen text |
cld |
mov ebx,25*65536+35 ; draw info text with function 4 |
mov ecx,0xffffff |
mov edx,text |
mov esi,40 |
newline: |
mov eax,4 |
int 0x40 |
add ebx,16 |
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 |
source db 'HEAT8M22.WAV ' |
destination db '192.168.1.24 ' |
tftp_filename: times 15 + 9 db 0 |
tftp_IP: dd 0 |
tftp_len: dd 0 |
addr dd 0x0 |
ya dd 0x0 |
fileposition dd 0 ; Points to the current point in the file |
filesize dd 0 ; The number of bytes written / left to write |
fileblocksize dw 0 ; The number of bytes to send in this frame |
text: |
db 'SOURCE FILE: xxxxxxxxxxxxxxx ' |
db 'HOST IP ADD: xxx.xxx.xxx.xxx ' |
db ' ' |
db 'WAVE FORMAT: 8 BIT,MONO,22050HZ ' |
db ' ' |
db ' SERVER -> PLAY FILE ' |
db ' ' |
db ' ' |
db 'x <- END MARKER, DONT DELETE ' |
labelt: |
db 'TFTP Wave Player' |
labellen: |
prompt: dd 0 |
promptlen: dd 0 |
p1: db 'Waiting for Command ' |
p1len: |
p9: db 'Define SB with setup' |
p9len: |
p2: db 'Sending File ' |
p2len: |
p3: db 'Playing File ' |
p3len: |
p4: db 'Complete ' |
p4len: |
p5: db 'Contacting Host... ' |
p5len: |
p6: db 'File not found. ' |
p6len: |
ack: |
db 00,04,0,1 |
ackLen: |
socketNum: |
dd 0 |
blockNumber: |
dw 0 |
; This must be the last part of the file, because the blockBuffer |
; continues at I_END. |
blockBuffer: |
db 00, 03, 00, 01 |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/tftpc/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm tftpc.asm tftpc |
@pause |
/programs/network/tftpc/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm tftpc.asm tftpc |
@pause |
/programs/network/tftpc/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 { ; mike.dld |
if ~a 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 |
} |
; language for programs |
lang fix ru ; ru en fr ge fi |
; 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 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/tftpc/trunk/tftpc.asm |
---|
0,0 → 1,986 |
; |
; TFTP Client |
; |
; 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 0x100000 ; required amount of memory |
dd 0x00000000 ; reserved=no extended header |
include 'lang.inc' |
include 'macros.inc' |
START: ; start of execution |
mov eax,40 ; Report events |
mov ebx,10000111b ; Stack 8 + defaults |
int 0x40 |
mov dword [prompt], p1 |
mov dword [promptlen], p1len - p1 |
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: ; Keys are not valid at this part of the |
mov eax,2 ; loop. 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 noclose |
; close socket before exiting |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
int 0x40 |
mov [socketNum], dword 0 |
mov eax,0xffffffff ; close this program |
int 0x40 |
noclose: |
cmp ah,2 ; copy file to local machine? |
jnz nocopyl |
mov dword [prompt], p5 |
mov dword [promptlen], p5len - p5 |
call draw_window ; |
; Copy File from Remote Host to this machine |
call translateData ; Convert Filename & IP address |
mov edi, tftp_filename + 1 |
mov [edi], byte 0x01 ; setup tftp msg |
call copyFromRemote |
jmp still |
nocopyl: |
cmp ah,3 ; Copy file to host? |
jnz nocopyh |
mov dword [prompt], p5 |
mov dword [promptlen], p5len - p5 |
call draw_window ; |
; Copy File from this machine to Remote Host |
call translateData ; Convert Filename & IP address |
mov edi, tftp_filename + 1 |
mov [edi], byte 0x02 ; setup tftp msg |
call copyToRemote |
jmp still |
nocopyh: |
cmp ah,4 |
jz f1 |
cmp ah,5 |
jz f2 |
jmp nof12 |
f1: |
mov [addr],dword source |
mov [ya],dword 35 |
jmp rk |
f2: |
mov [addr],dword destination |
mov [ya],dword 35+16 |
rk: |
mov ecx,15 |
mov edi,[addr] |
mov al,' ' |
rep stosb |
call print_text |
mov edi,[addr] |
f11: |
mov eax,10 |
int 0x40 |
cmp eax,2 |
jz fbu |
jmp still |
fbu: |
mov eax,2 |
int 0x40 ; get key |
shr eax,8 |
cmp eax,8 |
jnz nobs |
cmp edi,[addr] |
jz f11 |
sub edi,1 |
mov [edi],byte ' ' |
call print_text |
jmp f11 |
nobs: |
cmp eax,dword 31 |
jbe f11 |
cmp eax,dword 95 |
jb keyok |
sub eax,32 |
keyok: |
mov [edi],al |
call print_text |
add edi,1 |
mov esi,[addr] |
add esi,15 |
cmp esi,edi |
jnz f11 |
jmp still |
print_text: |
mov eax,13 |
mov ebx,103*65536+15*6 |
mov ecx,[ya] |
shl ecx,16 |
mov cx,8 |
mov edx,0x224466 |
int 0x40 |
mov eax,4 |
mov ebx,103*65536 |
add ebx,[ya] |
mov ecx,0xffffff |
mov edx,[addr] |
mov esi,15 |
int 0x40 |
ret |
nof12: |
jmp still |
;*************************************************************************** |
; Function |
; translateData |
; |
; Description |
; Coverts the filename and IP address typed in by the user into |
; a format suitable for the IP layer. |
; |
; The filename, in source, is converted and stored in tftp_filename |
; The host ip, in destination, is converted and stored in tftp_IP |
; |
;*************************************************************************** |
translateData: |
; first, build up the tftp command string. This includes the filename |
; and the transfer protocol |
; First, write 0,0 |
mov al, 0 |
mov edi, tftp_filename |
mov [edi], al |
inc edi |
mov [edi], al |
inc edi |
; Now, write the file name itself, and null terminate it |
mov ecx, 15 |
mov ah, ' ' |
mov esi, source |
td001: |
lodsb |
stosb |
cmp al, ah |
loopnz td001 |
cmp al,ah ; Was the entire buffer full of characters? |
jne td002 |
dec edi ; No - so remove ' ' character |
td002: |
mov [edi], byte 0 |
inc edi |
mov [edi], byte 'O' |
inc edi |
mov [edi], byte 'C' |
inc edi |
mov [edi], byte 'T' |
inc edi |
mov [edi], byte 'E' |
inc edi |
mov [edi], byte 'T' |
inc edi |
mov [edi], byte 0 |
mov esi, tftp_filename |
sub edi, esi |
mov [tftp_len], edi |
; Now, convert the typed IP address into a real address |
; No validation is done on the number entered |
; ip addresses must be typed in normally, eg |
; 192.1.45.24 |
xor eax, eax |
mov dh, 10 |
mov dl, al |
mov [tftp_IP], eax |
; 192.168.24.1 1.1.1.1 1. 9.2.3. |
mov esi, destination |
mov edi, tftp_IP |
mov ecx, 4 |
td003: |
lodsb |
sub al, '0' |
add dl, al |
lodsb |
cmp al, '.' |
je ipNext |
cmp al, ' ' |
je ipNext |
mov dh, al |
sub dh, '0' |
mov al, 10 |
mul dl |
add al, dh |
mov dl, al |
lodsb |
cmp al, '.' |
je ipNext |
cmp al, ' ' |
je ipNext |
mov dh, al |
sub dh, '0' |
mov al, 10 |
mul dl |
add al, dh |
mov dl, al |
lodsb |
ipNext: |
mov [edi], dl |
inc edi |
mov dl, 0 |
loop td003 |
ret |
;*************************************************************************** |
; Function |
; copyFromRemote |
; |
; Description |
; |
;*************************************************************************** |
copyFromRemote: |
xor eax, eax |
mov [filesize], eax |
mov eax, I_END + 512 ; This is the point where the file buffer is |
mov [fileposition], eax |
; Get a random # for the local socket port # |
mov eax, 3 |
int 0x40 |
mov ecx, eax |
shr ecx, 8 ; Set up the local port # with a random # |
; open socket |
mov eax, 53 |
mov ebx, 0 |
mov edx, 69 ; remote port |
mov esi, [tftp_IP] ; remote IP ( in intenet format ) |
int 0x40 |
mov [socketNum], eax |
; make sure there is no data in the socket - there shouldn't be.. |
cfr001: |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
int 0x40 ; any more data? |
cmp eax, 0 |
jne cfr001 ; yes, so get it |
; Now, request the file |
mov eax, 53 |
mov ebx, 4 |
mov ecx, [socketNum] |
mov edx, [tftp_len] |
mov esi, tftp_filename |
int 0x40 |
cfr002: |
mov eax,10 ; wait here for event |
int 0x40 |
cmp eax,1 ; redraw request ? |
je cfr003 |
cmp eax,2 ; key in buffer ? |
je cfr004 |
cmp eax,3 ; button in buffer ? |
je cfr005 |
; Any data to fetch? |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
int 0x40 |
cmp eax, 0 |
je cfr002 |
push eax ; eax holds # chars |
; Update the text on the display - once |
mov eax, [prompt] |
cmp eax, p3 |
je cfr008 |
mov dword [prompt], p3 |
mov dword [promptlen], p3len - p3 |
call draw_window ; |
cfr008: |
; we have data - this will be a tftp frame |
; read first two bytes - opcode |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte |
pop eax |
; bl holds tftp opcode. Can only be 3 (data) or 5 ( error ) |
cmp bl, 3 |
jne cfrerr |
push eax |
; do data stuff. Read block #. Read data. Send Ack. |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte |
mov [blockNumber], bl |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte |
mov [blockNumber+1], bl |
cfr007: |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
int 0x40 ; any more data? |
cmp eax, 0 |
je no_more_data ; no |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte |
mov esi, [fileposition] |
mov [esi], bl |
inc dword [fileposition] |
inc dword [filesize] |
jmp cfr007 |
no_more_data: |
; write the block number into the ack |
mov al, [blockNumber] |
mov [ack + 2], al |
mov al, [blockNumber+1] |
mov [ack + 3], al |
; send an 'ack' |
mov eax, 53 |
mov ebx, 4 |
mov ecx, [socketNum] |
mov edx, ackLen - ack |
mov esi, ack |
int 0x40 |
; If # of chars in the frame is less that 516, |
; this frame is the last |
pop eax |
cmp eax, 516 |
je cfr002 |
; Write the file |
mov eax, 33 |
mov ebx, source |
mov edx, [filesize] |
mov ecx, I_END + 512 |
mov esi, 0 |
int 0x40 |
jmp cfrexit |
cfrerr: |
; simple implementation on error - just read all data, and return |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
int 0x40 ; any more data? |
cmp eax, 0 |
jne cfrerr ; yes, so get it |
jmp cfr006 ; close socket and close app |
cfr003: ; redraw request |
call draw_window |
jmp cfr002 |
cfr004: ; key pressed |
mov eax,2 ; just read it and ignore |
int 0x40 |
jmp cfr002 |
cfr005: ; button |
mov eax,17 ; get id |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jne cfr002 ; If not, ignore. |
cfr006: |
; close socket |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
int 0x40 |
mov [socketNum], dword 0 |
mov eax,-1 ; close this program |
int 0x40 |
jmp $ |
cfrexit: |
; close socket |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
int 0x40 |
mov [socketNum], dword 0 |
mov dword [prompt], p4 |
mov dword [promptlen], p4len - p4 |
call draw_window ; |
ret |
;*************************************************************************** |
; Function |
; copyToRemote |
; |
; Description |
; |
;*************************************************************************** |
copyToRemote: |
mov eax,6 ; Read file from floppy (image) |
mov ebx,source |
mov ecx,0 |
mov edx,0xffffffff |
mov esi,I_END + 512 |
int 0x40 |
cmp eax,0xffffffff |
jnz filefound |
mov dword [prompt], p6 |
mov dword [promptlen], p6len - p6 |
call draw_window ; |
jmp ctr_exit |
filefound: |
mov [filesize], eax |
; First, set up the file pointers |
mov eax, 0x01000300 |
mov [blockBuffer], eax ; This makes sure our TFTP header is valid |
mov eax, I_END + 512 ; This is the point where the file buffer is |
mov [fileposition], eax |
mov eax, [filesize] |
cmp eax, 512 |
jb ctr000 |
mov eax, 512 |
ctr000: |
mov [fileblocksize], ax |
; Get a random # for the local socket port # |
mov eax, 3 |
int 0x40 |
mov ecx, eax |
shr ecx, 8 ; Set up the local port # with a random # |
; First, open socket |
mov eax, 53 |
mov ebx, 0 |
mov edx, 69 ; remote port |
mov esi, [tftp_IP] |
int 0x40 |
mov [socketNum], eax |
; write to socket ( request write file ) |
mov eax, 53 |
mov ebx, 4 |
mov ecx, [socketNum] |
mov edx, [tftp_len] |
mov esi, tftp_filename |
int 0x40 |
; now, we wait for |
; UI redraw |
; UI close |
; or data from remote |
ctr001: |
mov eax,10 ; wait here for event |
int 0x40 |
cmp eax,1 ; redraw request ? |
je ctr003 |
cmp eax,2 ; key in buffer ? |
je ctr004 |
cmp eax,3 ; button in buffer ? |
je ctr005 |
; Any data in the UDP receive buffer? |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
int 0x40 |
cmp eax, 0 |
je ctr001 |
; Update the text on the display - once |
mov eax, [prompt] |
cmp eax, p2 |
je ctr002 |
mov dword [prompt], p2 |
mov dword [promptlen], p2len - p2 |
call draw_window ; |
; we have data - this will be the ack |
ctr002: |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte - opcode |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte - opcode |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte - block (high byte) |
mov [blockNumber], bl |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte - block (low byte ) |
mov [blockNumber+1], bl |
ctr0022: |
mov eax, 53 |
mov ebx, 3 |
mov ecx, [socketNum] |
int 0x40 ; read byte (shouldn't have worked) |
mov eax, 53 |
mov ebx, 2 |
mov ecx, [socketNum] |
int 0x40 ; any more data? |
cmp eax, 0 |
jne ctr0022 ; yes, so get it, and dump it |
; If the ack is 0, it is to the request |
mov bx, [blockNumber] |
cmp bx, 0 |
je txd |
; now, the ack should be one more than the current field - otherwise, resend |
cmp bx, [blockBuffer+2] |
jne txre ; not the same, so send again |
; update the block number |
mov esi, blockBuffer + 3 |
mov al, [esi] |
inc al |
mov [esi], al |
cmp al, 0 |
jne ctr008 |
dec esi |
inc byte [esi] |
ctr008: |
; Move forward through the file |
mov eax, [fileposition] |
movzx ebx, word [fileblocksize] |
add eax, ebx |
mov [fileposition], eax |
; new .. |
; fs = 0 , fbs = 512 -> send with fbs = 0 |
cmp [filesize],0 |
jne no_special_end |
cmp [fileblocksize],512 |
jne no_special_end |
mov ax,0 |
jmp ctr006 |
no_special_end: |
mov eax, [filesize] |
cmp eax, 0 |
je ctr009 |
cmp eax, 512 |
jb ctr006 |
mov eax, 512 |
ctr006: |
mov [fileblocksize], ax |
txd: |
; Readjust the file size variable ( before sending ) |
mov eax, [filesize] |
movzx ebx, word [fileblocksize] |
sub eax, ebx |
mov [filesize], eax |
txre: |
; Copy the fragment of the file to the block buffer |
movzx ecx, word [fileblocksize] |
mov esi, [fileposition] |
mov edi, I_END |
cld |
rep movsb |
; send the file data |
mov eax, 53 |
mov ebx, 4 |
mov ecx, [socketNum] |
movzx edx, word [fileblocksize] |
add edx, 4 |
mov esi, blockBuffer |
int 0x40 |
jmp ctr001 |
ctr003: ; redraw |
call draw_window |
jmp ctr001 |
ctr004: ; key |
mov eax,2 ; just read it and ignore |
int 0x40 |
jmp ctr001 |
ctr005: ; button |
mov eax,17 ; get id |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jne ctr001 |
; close socket |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
int 0x40 |
mov [socketNum], dword 0 |
mov eax,-1 ; close this program |
int 0x40 |
jmp $ |
ctr009: |
; close socket |
mov eax, 53 |
mov ebx, 1 |
mov ecx, [socketNum] |
int 0x40 |
mov dword [prompt], p4 |
mov dword [promptlen], p4len - p4 |
call draw_window ; |
ctr_exit: |
ret |
; ********************************************* |
; ******* 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,100*65536+170 ; [y start] *65536 + [y size] |
mov edx,0x03224466 ; color of work area RRGGBB |
mov esi,0x00334455 ; color of grab bar RRGGBB,8->color gl |
mov edi,0x00ddeeff ; 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,labelt ; pointer to text beginning |
mov esi,labellen-labelt ; text length |
int 0x40 |
mov eax,8 ; COPY BUTTON |
mov ebx,20*65536+190 |
mov ecx,79*65536+15 |
mov edx,2 |
mov esi,0x557799 |
int 0x40 |
mov eax,8 ; DELETE BUTTON |
mov ebx,20*65536+190 |
mov ecx,111*65536+15 |
mov edx,3 |
mov esi,0x557799 |
int 0x40 |
mov eax,8 |
mov ebx,200*65536+10 |
mov ecx,34*65536+10 |
mov edx,4 |
mov esi,0x557799 |
int 0x40 |
mov eax,8 |
mov ebx,200*65536+10 |
mov ecx,50*65536+10 |
mov edx,5 |
mov esi,0x557799 |
int 0x40 |
; Copy the file name to the screen buffer |
; file name is same length as IP address, to |
; make the math easier later. |
cld |
mov esi,source |
mov edi,text+13 |
mov ecx,15 |
rep movsb |
; copy the IP address to the screen buffer |
mov esi,destination |
mov edi,text+40+13 |
mov ecx,15 |
rep movsb |
; copy the prompt to the screen buffer |
mov esi,[prompt] |
mov edi,text+280 |
mov ecx,[promptlen] |
rep movsb |
; Re-draw the screen text |
cld |
mov ebx,25*65536+35 ; draw info text with function 4 |
mov ecx,0xffffff |
mov edx,text |
mov esi,40 |
newline: |
mov eax,4 |
int 0x40 |
add ebx,16 |
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 |
source db 'KERNEL.ASM ' |
destination db '192.168.1.23 ' |
tftp_filename: times 15 + 9 db 0 |
tftp_IP: dd 0 |
tftp_len: dd 0 |
addr dd 0x0 |
ya dd 0x0 |
fileposition dd 0 ; Points to the current point in the file |
filesize dd 0 ; The number of bytes written / left to write |
fileblocksize dw 0 ; The number of bytes to send in this frame |
text: |
db 'SOURCE FILE: xxxxxxxxxxxxxxx ' |
db 'HOST IP ADD: xxx.xxx.xxx.xxx ' |
db ' ' |
db ' COPY HOST -> LOCAL ' |
db ' ' |
db ' COPY LOCAL -> HOST ' |
db ' ' |
db ' ' |
db 'x <- END MARKER, DONT DELETE ' |
labelt: |
db 'TFTP Client' |
labellen: |
prompt: dd 0 |
promptlen: dd 0 |
p1: db 'Waiting for Command' |
p1len: |
p2: db 'Sending File ' |
p2len: |
p3: db 'Receiving File ' |
p3len: |
p4: db 'Tranfer Complete ' |
p4len: |
p5: db 'Contacting Host... ' |
p5len: |
p6: db 'File not found. ' |
p6len: |
ack: |
db 00,04,0,1 |
ackLen: |
socketNum: |
dd 0 |
blockNumber: |
dw 0 |
; This must be the last part of the file, because the blockBuffer |
; continues at I_END. |
blockBuffer: |
db 00, 03, 00, 01 |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/ym/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm ym.asm ym |
@pause |
/programs/network/ym/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm ym.asm ym |
@pause |
/programs/network/ym/trunk/ym.asm |
---|
0,0 → 1,1087 |
; Yahoo Messanger for MenuetOS |
; Compile with FASM for Menuet |
;B+ System header |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd START |
dd I_END |
dd 0x100000 |
dd 0x7fff0 |
dd 0x0,0x0 |
;E:. |
include 'lang.inc' |
;B+ Definitions |
v_sp equ 330 |
h_sp equ 400 |
fr_sp equ 120 |
line_wid equ 45 |
fr_max_lines equ 17 |
;memory |
sys_colors equ I_END |
text_zone equ sys_colors+4*10 |
;friend_zone equ text_zone+45*25 ;uncom |
;friend_zone+32*fr_max_lines |
;E:. |
START: |
;B+ Main execution |
call clear_text |
red: |
call draw_window |
still: |
mov ebx,50 |
mov eax,23 |
int 0x40 |
cmp eax,1 |
je red |
cmp eax,2 |
je key |
cmp eax,3 |
je button |
call check_message |
jmp still |
key: |
mov eax,2 |
int 0x40 |
cmp [is_connect],0 |
je still |
call send_key_string |
jmp still |
button: |
mov eax,17 |
int 0x40 |
cmp ah,1 |
jne noclose |
mov eax,-1 |
int 0x40 |
jmp $ |
noclose: |
;B+ Check friend |
cmp ah,2 |
jb .no_friend |
cmp ah,100 |
ja .no_friend |
;pressed number |
sub ah,2 |
shr ax,8 |
;find real name |
mov [friend_p],friend_zone |
mov edi,0 |
.next: |
push [friend_p] |
call test_friend |
jc .group |
inc edi |
.group: |
cmp di,ax |
pop ebx |
jbe .next |
inc ebx |
;exact place |
mov ecx,[friend_p] |
sub ecx,ebx |
dec ecx |
;Insert in send |
cmp al,10 |
jb .good |
add al,'A'-'0'-10 |
.good: |
add al,'0' |
mov [view_text+1],al |
;Clear old a. friend |
pusha |
mov ebx,(h_sp-140) shl 16 + 132 |
mov ecx,(v_sp-53) shl 16 + 10 |
mov edx,[sys_colors+4*5] |
mov eax,13 |
int 0x40 |
popa |
;show item |
mov [f_name_b],ebx |
mov [f_name_l],ecx |
call show_a_friend |
jmp still |
.no_friend: |
;E:. |
;B+ Check User / Password |
cmp ah,103 |
je input_username |
cmp ah,104 |
je input_password |
;E:. |
;B+ Connect / Dis... |
cmp ah,101 |
je yahoo_c |
cmp ah,102 |
je yahoo_d |
;E:. |
jmp still |
;E:. |
draw_window: |
;B+ Draw window |
mov ebx,1 |
mov eax,12 |
int 0x40 |
mov ebx,3 |
mov ecx,sys_colors |
mov edx,10*4 |
mov eax,48 |
int 0x40 |
mov ebx,150*65536+h_sp |
mov ecx,100*65536+v_sp |
mov edx,[sys_colors+4*5] |
or edx,0x02000000 |
mov esi,[sys_colors+4*1] |
or esi,0x80000000 |
mov edi,[sys_colors+4*0] |
mov eax,0 |
int 0x40 |
mov ebx,8*65536+8 |
mov ecx,[sys_colors+4*4] |
or ecx,0x10000000 |
mov edx,caption |
mov esi,caption_end-caption |
mov eax,4 |
int 0x40 |
mov ebx,(400-19) shl 16 + 12 |
mov ecx,5 shl 16 + 12 |
mov edx,1 |
mov esi,[sys_colors+4*2] |
mov eax,8 |
int 0x40 |
;B+ Friend panel |
mov ebx,(h_sp-fr_sp) shl 16 + 3 |
mov ecx,20 shl 16 + v_sp-31 -56 |
mov edx,[sys_colors+4*9] |
mov eax,13 |
int 0x40 |
call show_friends |
;E:. |
;B+ Input panel |
mov ebx,5 shl 16 + h_sp-9 |
mov ecx,(v_sp-31 -33-3) shl 16 + 3 |
mov edx,[sys_colors+4*9] |
mov eax,13 |
int 0x40 |
mov ebx,(h_sp-(fr_sp-12)*8/6) shl 16 + 4 |
mov ecx,(v_sp-31-33) shl 16 + 30 |
int 0x40 |
mov ebx,(h_sp-8) shl 16 + 4 |
int 0x40 |
call show_a_friend |
call show_string |
;E:. |
;B+ Login panel |
mov ebx,5 shl 16 + h_sp-9 |
mov ecx,(v_sp-35) shl 16 + 31 |
mov edx,[sys_colors+4*9] |
mov eax,13 |
int 0x40 |
mov ebx,(5+2+8+(user_txt_end-user_txt)*6) shl 16 + 6*15+7 |
mov ecx,(v_sp-32) shl 16 + 12 |
mov edx,[sys_colors+4*5] |
int 0x40 |
mov ebx,(171+2+8+(psw_txt_end-psw_txt)*6) shl 16 + 6*23+7 |
mov ecx,(v_sp-32) shl 16 + 12 |
int 0x40 |
;connect button |
mov ebx,(h_sp-128) shl 16 + (con_txt_end-con_txt)*6 + 7 |
mov ecx,(v_sp-18) shl 16 + 12 |
mov edx,101 |
mov esi,[sys_colors+4*6] |
mov eax,8 |
int 0x40 |
;disconnect button |
shl ebx,16 |
add ebx,(h_sp-128+3) shl 16 + (dis_txt_end-dis_txt)*6 + 7 |
mov edx,102 |
int 0x40 |
;user button |
mov ebx,8 shl 16 + (user_txt_end-user_txt)*6 + 5 |
mov ecx,(v_sp-18-15) shl 16 + 12 |
mov edx,103 |
int 0x40 |
;password button |
mov ebx,174 shl 16 + (psw_txt_end-psw_txt)*6 + 5 |
mov edx,104 |
int 0x40 |
;login text |
mov ebx,11 shl 16 + v_sp-15 |
mov ecx,[sys_colors+4*7] |
mov edx,login_txt |
mov esi,login_txt_end-login_txt |
mov eax,4 |
int 0x40 |
;user text |
mov ebx,11 shl 16 + v_sp-15-15 |
mov edx,user_txt |
mov esi,user_txt_end-user_txt |
int 0x40 |
;password text |
mov ebx,(174+5) shl 16 + v_sp-15-15 |
mov edx,psw_txt |
mov esi,psw_txt_end-psw_txt |
int 0x40 |
;connect text |
mov ebx,(h_sp-128+5) shl 16 + v_sp-15 |
mov edx,con_txt |
mov esi,con_txt_end-con_txt |
int 0x40 |
;disconnect text |
add ebx,((con_txt_end-con_txt)*6+8 + 3) shl 16 |
mov edx,dis_txt |
mov esi,dis_txt_end-dis_txt |
int 0x40 |
call show_username |
call show_password |
;E:. |
call show_text |
mov ebx,2 |
mov eax,12 |
int 0x40 |
ret |
;E:. |
show_friends: |
;B+ Show friend list |
cmp [last_friend_place],friend_zone |
jne .yes_show |
ret |
.yes_show: |
;show button |
mov ebx,(h_sp-fr_sp+5) shl 16 + 10 |
mov ecx,(20+3) shl 16 + 10 |
mov edx,2 |
mov esi,[sys_colors+4*6] |
mov eax,8 |
mov edi,0 |
mov [friend_p],friend_zone |
.next_button: |
call test_friend |
jc .no_b |
int 0x40 |
inc edx |
.no_b: |
inc edi |
add ecx,15 shl 16 |
cmp edi,[last_friend_line] |
jne .next_button |
;show numbers |
mov [digit],'0'-1 |
mov ebx,(h_sp-fr_sp+8) shl 16 + (20+3)+2 |
;mov ecx,[sys_colors+4*7] |
mov edx,digit |
mov esi,1 |
mov eax,4 |
mov edi,0 |
mov [friend_p],friend_zone |
push edx |
.next_digit: |
mov edx,[friend_p] |
call test_friend |
cmp [edx],byte 1 |
je .no_item |
inc [digit] |
cmp [digit],'9'+1 |
jne .good |
mov [digit],'A' |
.good: |
;add ebx,1 shl 16 |
cmp [edx],byte 2 |
mov edx,[esp] |
mov ecx,[sys_colors+4*6] |
call hi_light |
jne .no_online |
mov ecx,[sys_colors+4*7] |
;int 0x40 |
;or ecx,0x10000000 |
.no_online: |
;sub ebx,1 shl 16 |
int 0x40 |
;and ecx,not 0x10000000 |
.no_item: |
add ebx,15 |
inc edi |
cmp edi,[last_friend_line] |
jne .next_digit |
add esp,4 |
;show names |
mov ebx,(h_sp-fr_sp+8 + 10) shl 16 + (20+3)+2 |
mov ecx,[sys_colors+4*8] |
mov eax,4 |
mov edi,0 |
mov [friend_p],friend_zone |
mov esi,4 |
.next_name: |
mov edx,[friend_p] |
call test_friend |
mov esi,[friend_p] |
inc edx |
sub esi,edx |
and ebx,0xffff |
or ebx,(h_sp-fr_sp+8 + 10) shl 16 |
cmp [edx-1],byte 1 |
jne .no_group |
sub ebx,12 shl 16 |
.no_group: |
int 0x40 |
add ebx,15 |
inc edi |
cmp edi,[last_friend_line] |
jne .next_name |
ret |
.p db 16 ;> |
digit db '0' |
;last_friend_line dd 0x0 ;uncom |
test_friend: |
push eax |
mov eax,[friend_p] |
clc |
cmp [eax],byte 1 |
jne .no_hide |
stc |
.no_hide: |
pushf |
.next: |
inc [friend_p] |
mov eax,[friend_p] |
cmp [eax],byte 0 |
jne .next |
inc [friend_p] |
popf |
pop eax |
ret |
friend_p dd 0x0 |
hi_light: |
pushf |
add ecx,0x400000 |
test ecx,0xb00000 |
jnz .no_red_plus |
sub ecx,0x400000 |
.no_red_plus: |
add ecx,0x004000 |
test ecx,0x00b000 |
jnz .no_green_plus |
sub ecx,0x008000 |
.no_green_plus: |
add ecx,0x000040 ;80 |
test ecx,0x0000b0 ;80 |
jnz .no_blue_plus |
sub ecx,0x000040 ;100 |
.no_blue_plus: |
popf |
ret |
;E:. |
;B+ Message text op. |
clear_text: |
mov edi,text_zone |
mov ecx,45*26 |
mov al,0 |
cld |
rep stosb |
ret |
show_text: |
mov ebx,7 shl 16 + (20+3) ;+ 2 |
mov ecx,[sys_colors+4*8] |
mov edx,text_zone+45 |
mov esi,45 |
mov eax,4 |
mov edi,0 |
.next_line: |
cmp [edx-1],byte 0 |
jne .shift |
int 0x40 |
.next: |
add ebx,10 |
add edx,45 |
inc edi |
cmp edi,24 |
jne .next_line |
ret |
.shift: |
add ebx,3 shl 16 |
int 0x40 |
sub ebx,3 shl 16 |
jmp .next |
scroll_text: |
pusha |
;move text |
mov edi,text_zone |
mov esi,edi |
add esi,line_wid |
mov ecx,line_wid*24 |
cld |
rep movsb |
;clear last line |
mov ecx,line_wid |
mov al,0 |
rep stosb |
;clear zone |
mov ebx,7 shl 16 + line_wid*6+2 |
mov ecx,(25-2) shl 16 + 24*10-2 +2 |
mov edx,[sys_colors+4*5] |
mov eax,13 |
int 0x40 |
;show text |
call show_text |
popa |
ret |
show_message: |
;ebx - begin |
;ecx - length |
mov eax,[.m_p] |
add eax,ecx |
.test: |
cmp eax,text_zone+line_wid*25-1 |
jb .good1 |
call scroll_text |
sub eax,line_wid |
sub [.m_p],line_wid |
jmp .test |
.good1: |
cmp [.m_p],text_zone+line_wid |
jae .good2 |
add ebx,line_wid |
add [.m_p],line_wid |
sub ecx,line_wid |
jmp .good1 |
.good2: |
; |
push ecx |
mov esi,ebx |
mov edi,[.m_p] |
cld |
rep movsb |
pop ecx |
;find v place |
mov eax,[.m_p] |
sub eax,text_zone+line_wid |
mov ebx,line_wid |
xor edx,edx |
div ebx |
xor edx,edx |
mov ebx,10 |
mul ebx |
mov ebx,eax |
;show line |
add ebx,7 shl 16 + 23 ;+2 |
mov ecx,[sys_colors+4*8] |
mov edx,[.m_p] |
mov esi,line_wid |
mov eax,4 |
int 0x40 |
add ebx,3 shl 16 |
.next_line: |
add ebx,10 |
add edx,line_wid |
cmp [edx-1],byte 0 |
je .good3 |
int 0x40 |
jmp .next_line |
.good3: |
mov [.m_p],edx |
ret |
.m_p dd text_zone+45 |
;E:. |
;B+ Show current people |
show_a_friend: |
mov ebx,(h_sp-137) shl 16 + v_sp-52 |
mov ecx,[sys_colors+4*8] |
or ecx,0x10000000 |
mov edx,[f_name_b] |
mov esi,[f_name_l] |
mov eax,4 |
int 0x40 |
ret |
f_name_b dd fnb |
f_name_l dd 10 |
fnb: |
db 'yahoo_help' |
;E:. |
;B+ Input strings |
send_key_string: |
;B+ Test active keys |
cmp ah,13 |
je send_text |
cmp ah,27 |
je clear_input_text |
cmp ah,8 |
je .backs_text |
;E:. |
mov [.this_c],ah |
cmp [.c_pl],123 |
jne .show |
ret |
.show: |
;save char |
mov ebx,[.c_pl] |
mov [in_text+ebx],ah |
inc [.c_pl] |
;show char |
mov ebx,[.xy] |
mov ecx,[sys_colors+4*8] |
mov edx,.this_c |
mov esi,1 |
mov eax,4 |
int 0x40 |
; |
cmp [.c_pl],41 |
je .new_line |
cmp [.c_pl],82 |
je .new_line |
add [.xy],6 shl 16 |
call show_cursor |
ret |
;;; |
.new_line: |
and [.xy],0x0000ffff |
add [.xy],9 shl 16 + 9 |
call show_cursor |
ret |
.this_c db ' ' |
.c_pl dd 0x0 |
.xy dd 7 shl 16 + v_sp-62 |
;B+ Special keys - action |
.backs_text: |
; |
cmp [.c_pl],0 |
jne .yes_back |
ret |
.yes_back: |
cmp [.c_pl],41 |
je .back_line |
add [.xy],2 shl 16 |
cmp [.c_pl],82 |
je .back_line |
sub [.xy],2 shl 16 |
.next: |
; |
sub [.xy],6 shl 16 |
dec [.c_pl] |
mov eax,[.c_pl] |
mov bl,[in_text+eax] |
mov [.this_c],bl |
mov ebx,[.xy] |
mov ecx,[sys_colors+4*5] |
mov edx,.this_c |
mov esi,1 |
mov eax,4 |
int 0x40 |
mov ebx,[.c_pl] |
mov [in_text+ebx],byte 0 |
jmp show_cursor |
; |
.back_line: |
;and [.xy],0x0000ffff |
sub [.xy],9 |
add [.xy],(253-9) shl 16 |
jmp .next |
send_text: |
;show text to message board |
mov ebx,view_text |
mov ecx,[send_key_string.c_pl] |
add ecx,3 |
call show_message |
;send message to internet |
;call internet_send |
clear_input_text: |
;prepare new message |
;; clear memory |
mov edi,in_text |
mov ecx,255/4 |
xor eax,eax |
cld |
rep stosd |
;; clear zone |
mov ebx,5 shl 16 + h_sp-140-9 |
mov ecx,(v_sp-31 -33) shl 16 + 29 |
mov edx,[sys_colors+4*5] |
mov eax,13 |
int 0x40 |
;; move cursor |
mov ebx,7 shl 16 + v_sp-62 |
mov [send_key_string.xy],ebx |
mov [show_cursor.old_xy],ebx |
;; clear place |
xor ebx,ebx |
mov [send_key_string.c_pl],ebx |
; call show_cursor |
; ret |
;E:. |
show_cursor: |
;login text |
; mov ebx,4 shl 16 + v_sp-64 |
mov ebx,[.old_xy] |
sub ebx,3 shl 16 + 2 |
mov ecx,[sys_colors+4*5] |
mov edx,curs |
mov esi,1 |
mov eax,4 |
int 0x40 |
add ebx,4 |
int 0x40 |
mov ebx,[send_key_string.xy] |
mov [.old_xy],ebx |
sub ebx,3 shl 16 + 2 |
mov ecx,0xffffff;[sys_colors+4*8] |
int 0x40 |
add ebx,4 |
int 0x40 |
ret |
.old_xy dd 7 shl 16 + v_sp-62 |
curs db '|' |
show_string: |
mov ebx,7 shl 16 + v_sp-62 |
mov ecx,[sys_colors+4*8] |
mov edx,in_text |
mov esi,41 |
mov eax,4 |
int 0x40 |
add ebx,2 shl 16 + 9 |
add edx,41 |
int 0x40 |
add ebx,9 |
add edx,41 |
int 0x40 |
call show_cursor |
ret |
view_text db 16,'?',16 |
in_text: times 255 db 0 |
;E:. |
;B+ Friends... |
add_friend: |
;ebx - begin |
; [ebx]=1 - Group name |
; [ebx]=2 - Active user |
; [ebx]=other - Non active user |
;ecx - length |
cmp [last_friend_line],fr_max_lines-1 |
je .no_more |
test ecx,not 31 |
jnz .no_more ; very long id name |
inc [last_friend_line] |
mov esi,ebx |
mov edi,[last_friend_place] |
inc ecx |
add [last_friend_place],ecx |
dec ecx |
cld |
rep movsb |
mov al,0 |
stosb |
stosb |
.no_more: |
ret |
last_friend_place dd fr_e ;del |
;last_friend_place dd friend_zone ;uncom |
find_friend: |
push ebx ecx |
mov edx,friend_zone |
mov esi,0 |
mov edi,[last_friend_line] |
; inc edi ;? uncom ? |
.next_name: |
cmp [edx],byte 1 |
je .no_find ;Group |
inc edx |
dec ecx |
.next: |
mov al,[edx] |
mov ah,[ebx] |
cmp ah,al |
jne .no_find |
inc edx |
inc ebx |
dec ecx |
jne .next |
cmp [edx],byte 0 |
jne .no_find |
;find |
mov eax,esi |
cmp esi,9 |
ja .letter |
add al,'0' |
ret |
.letter: |
add al,'A'-10 |
ret |
.no_find: |
cmp [edx],byte 0 |
je .go_next |
inc edx |
jmp .no_find |
.go_next: |
dec edi |
je .noting |
mov ebx,[esp+4] |
mov ecx,[esp] |
inc esi |
jmp .next_name |
.noting: |
mov al,'!' |
pop ecx ebx |
ret |
;E:. |
;B+ Connect / Disconnect |
yahoo_c: |
call connect |
cmp eax,0 |
jne still ;not connected |
mov [is_connect],0x1 |
jmp still |
yahoo_d: |
cmp [is_connect],0x0 |
je .noting |
call disconnect |
; |
;stop connection |
mov [is_connect],0x0 |
; |
;clear text |
mov ah,27 |
call send_key_string |
; |
;clear friends |
; mov [last_friend_line],0x0 ;uncom |
; mov [last_friend_place],friend_zone ;uncom |
; |
;set dafaut friend |
mov [f_name_b],fnb |
mov [f_name_l],10 |
mov [view_text+1],'?' |
call draw_window |
.noting: |
jmp still |
is_connect dd 0x0 |
;E:. |
;B+ Load username / password |
input_username: |
mov edi,username |
mov [edi],byte '_' |
inc edi |
mov ecx,16-1 |
cld |
rep stosb |
mov [.unp],username |
.next: |
call show_username |
;get enen |
mov eax,10 |
int 0x40 |
cmp eax,1 |
je .end |
cmp eax,3 |
je .end |
;key |
mov eax,2 |
int 0x40 |
cmp ah,13 |
je .end |
cmp ah,8 |
jne .no_back |
cmp [.unp],username |
je .next |
dec [.unp] |
mov ebx,[.unp] |
mov [ebx],byte '_' |
mov [ebx+1],byte 0 |
jmp .next |
.no_back: |
cmp [.unp],username+16 |
je .next |
cmp ah,'0' |
jb .bad |
mov ebx,[.unp] |
mov [ebx],ah |
mov [ebx+1],byte '_' |
inc [.unp] |
.bad: |
jmp .next |
.end: |
;del cursor |
mov ebx,[.unp] |
mov [ebx],byte 0 |
call show_username |
;clear password |
mov [password],byte 0 |
;hide password |
mov ebx,(2+41*6) shl 16 + v_sp-15-15 |
mov ecx,[sys_colors+4*5] |
mov edx,f_password |
mov esi,4 |
mov eax,4 |
int 0x40 |
jmp still |
.unp dd username |
show_username: |
;hide |
mov ebx,(4+12*6-1) shl 16 + 16*6+1 |
mov ecx,(v_sp-15-15) shl 16 + 9 |
mov edx,[sys_colors+4*5] |
mov eax,13 |
int 0x40 |
;show |
mov ebx,(4+12*6) shl 16 + v_sp-15-15 |
mov ecx,[sys_colors+4*8] |
mov edx,username |
mov esi,16 |
mov eax,4 |
int 0x40 |
ret |
username: times (16+1) db 0 |
input_password: |
;clear |
mov edi,password |
mov ecx,24 |
mov al,0 |
cld |
rep stosb |
mov [.unp],password |
;hide password |
mov ebx,(2+41*6) shl 16 + v_sp-15-15 |
mov ecx,[sys_colors+4*5] |
mov edx,f_password |
mov esi,4 |
mov eax,4 |
int 0x40 |
.next: |
;get enen |
mov eax,10 |
int 0x40 |
cmp eax,1 |
je still |
cmp eax,3 |
je still |
;key |
mov eax,2 |
int 0x40 |
cmp [.unp],password+24 |
je .no_next |
cmp ah,13 |
jne .no_still |
.no_next: |
call show_password |
jmp still |
.no_still: |
mov ebx,[.unp] |
mov [ebx],ah |
inc [.unp] |
jmp .next |
.unp dd password |
show_password: |
cmp [password],byte 0 |
je .end |
mov ebx,(2+41*6) shl 16 + v_sp-15-15 |
mov ecx,[sys_colors+4*8] |
mov edx,f_password |
mov esi,4 |
mov eax,4 |
int 0x40 |
.end: |
ret |
f_password db '####' |
password: times (24+1) db 0 |
;E:. |
;B+ INTERNET |
;Functions: |
;call add_friend |
; ebx+1 - pointer to name |
; [ebx]=1 - Group name |
; [ebx]=2 - Active user |
; [ebx]=other - Non active user |
; ecx - length |
; |
;call show_message |
; ebx - begin of string |
; ecx - length |
; ----- |
; NOTE Use format: |
; (<char>) <message> |
; where: |
; <char> - friend user char |
; <message> - message from friend |
; |
;call find_friend |
; ebx - begin of name |
; ecx - length |
; ret: |
; al - friend user char |
; ----- |
; NOTE currenly don't show message if al='!' |
;Variables |
;usernave (zero terminated) |
;password (zero terminated) |
;f_name_b - current friend user (to send) |
;f_name_l - ^ length |
;Memory |
; (friend_zone+32*fr_max_lines) < addr: [addr] - free |
connect: |
;conect to yahoo |
;return 0 if OK |
;return <>0 if some other event (sys.func.23) |
mov eax,0 |
ret |
disconnect: |
;disconnect |
ret |
check_message: |
;test receive messages |
ret |
;E:. |
;B+ Test data ;del |
friend_zone: ;del |
db 1,'First:',0 ;del |
db 2,'hahaha',0 ;del |
db 3,'second',0 ;del |
db 3,'menuetos',0 ;del |
db 1,'Treti:',0 ;del |
db 2,'fourth',0 ;del |
fr_e db 0 ;del |
;del |
times 200 db 0 ;del |
;del |
last_friend_line dd 0x6 ;del |
;E:. ;del |
;B+ Data area |
;caption db 'Yahoo Messanger for MenuetOS' |
caption db 'Messinger (Yahoo Compatible)' |
caption_end: |
;User / Password |
login_txt db 'STATUS: SESSION: ___.___.___.___' |
;VISIBLE |
;HIDDEN |
login_txt_end: |
user_txt db 'USER ID ->' |
user_txt_end: |
psw_txt db 'PASSWORD ->' |
psw_txt_end: |
con_txt db 'CONNECT' |
con_txt_end: |
dis_txt db 'DISCONNECT' |
dis_txt_end: |
;E:. |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |