From 59eaa9f2bd1c57e0f050e7a0a9a3497b3192cd45 Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Wed, 16 May 2007 19:12:34 +0000 Subject: [PATCH] small optimization. reduce code size git-svn-id: svn://kolibrios.org@501 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/data32.inc | 25 +++++--- kernel/trunk/fs/parse_fn.inc | 83 +++++++++++++------------ kernel/trunk/kernel.asm | 113 +++++++++++++++++++---------------- 3 files changed, 126 insertions(+), 95 deletions(-) diff --git a/kernel/trunk/data32.inc b/kernel/trunk/data32.inc index 5fe9fdc99d..9c01167f90 100644 --- a/kernel/trunk/data32.inc +++ b/kernel/trunk/data32.inc @@ -83,14 +83,23 @@ szEXPORTS db 'EXPORTS',0 szIMPORTS db 'IMPORTS',0 firstapp db '%sys%/LAUNCHER',0 - char dd 0,0,0 - dd 2560 - dd FONT_I - db '%sys%/FONTS/CHAR.MT',0 - char2 dd 0,0,0 - dd 2560 - dd FONT_II - db '%sys%/FONTS/CHAR2.MT',0 + +if 0 +char dd 0,0,0 + dd 2560 + dd FONT_I + db '%sys%/FONTS/CHAR.MT',0 + +char2 dd 0,0,0 + dd 2560 + dd FONT_II + db '%sys%/FONTS/CHAR2.MT',0 +else + +char db '%sys%/FONTS/CHAR.MT',0 +char2 db '%sys%/FONTS/CHAR2.MT',0 + +end if bootpath db '/KOLIBRI ' diff --git a/kernel/trunk/fs/parse_fn.inc b/kernel/trunk/fs/parse_fn.inc index 7f6ac411e8..2637e03158 100644 --- a/kernel/trunk/fs/parse_fn.inc +++ b/kernel/trunk/fs/parse_fn.inc @@ -13,13 +13,15 @@ locals param rb 60 val rb 60 tmpsrc rb 60 ; временное хранение преобразования -endl +endl pushad - + mov esi,[sourc] - mov edi,ebp - add edi,tmpsrc-ebp +; mov edi,ebp +; add edi,tmpsrc-ebp + lea edi, [tmpsrc] + @@: lodsb stosb @@ -29,55 +31,62 @@ endl mov al,[conf_file_loaded] ; требуется при обращении к первому файлу (конфигу) or al,al jnz @use_replace - + jmp full_file_name_exit - + ;-------------------------------- @use_replace: - + xor eax,eax .loop: push eax - mov ebx,ebp - add ebx,param-ebp - mov ecx,ebp - add ecx,val-ebp +; mov ebx,ebp +; add ebx,param-ebp +; mov ecx,ebp +; add ecx,val-ebp + lea ebx, [param] + lea ecx, [val] invoke ini.get_par,sect, ebx, ecx, eax mov bl,[param] or bl,bl jz .done - mov eax,ebp - add eax,tmpsrc-ebp - mov ebx,ebp - add ebx,param-ebp - mov ecx,ebp - add ecx,val-ebp - mov edx,[dest] +; mov eax,ebp +; add eax,tmpsrc-ebp +; mov ebx,ebp +; add ebx,param-ebp +; mov ecx,ebp +; add ecx,val-ebp + lea eax, [tmpsrc] + lea ebx, [param] + lea ecx, [val] + mov edx,[dest] stdcall full_file_name_parse, eax,edx,ebx,ecx - + mov esi,[dest] - mov edi,ebp - add edi,tmpsrc-ebp +; mov edi,ebp +; add edi,tmpsrc-ebp + lea edi, [tmpsrc] @@: lodsb stosb or al,al jnz @b - + pop eax inc eax jmp .loop - -.done: + +.done: pop eax full_file_name_exit: - mov eax,ebp - add eax,tmpsrc-ebp +; mov eax,ebp +; add eax,tmpsrc-ebp + lea eax, [tmpsrc] stdcall full_file_name_parse , eax , [dest], sysdir_ , sys_path popad ret @@ -104,7 +113,7 @@ proc full_file_name_parse stdcall,sourc,dest,def,dval je @@bad_s cmp dl,0 je @@good - + or cl,0x20 or dl,0x20 cmp cl,dl @@ -116,8 +125,8 @@ proc full_file_name_parse stdcall,sourc,dest,def,dval @@bad_s: cmp dl,0 - je @@good - + je @@good + @@bad: mov edi,[dest] mov esi,[sourc] @@ -136,23 +145,23 @@ proc full_file_name_parse stdcall,sourc,dest,def,dval lodsb stosb or al,al - jnz @b + jnz @b -@@goodl: +@@goodl: pop esi dec edi @@: lodsb - stosb + stosb or al,al - jnz @b + jnz @b @@ret_ok: popad ret -endp - +endp + sys_dir_mess: db 'System dir is ' sys_path: db '/HD0/1/KOLIBRI',0,0 sysdir_ db '%sys%',0 @@ -176,8 +185,8 @@ Parser_params: mov [sys_path+6],dword '/KOL' mov [sys_path+10],dword 'IBRI' mov [sys_path+14],word 0 ;0x002F - + .done: popad ret - \ No newline at end of file + diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index 38b601f87c..d0ddae999a 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -552,27 +552,18 @@ no_lib_load: ; LOAD FONTS I and II -; mov esi,char -; xor ebx,ebx -; mov ecx,2560 -; mov edx,FONT_I -; call fs_RamdiskRead -; mov esi,char2 -; xor ebx,ebx -; mov ecx,2560;26000 -; mov edx,FONT_II -; call fs_RamdiskRead - - pushad - push eax - mov eax,char - call file_system_lfn - mov eax,char2 - call file_system_lfn - pop eax - popad +; pushad +; push eax +; mov eax,char +; call file_system_lfn +; mov eax,char2 +; call file_system_lfn +; pop eax +; popad + stdcall read_file, char, FONT_I, 0, 2560 + stdcall read_file, char2, FONT_II, 0, 2560 mov esi,boot_fonts call boot_log @@ -657,10 +648,10 @@ no_lib_load: mov esi,boot_setostask call boot_log - mov eax, fpu_data - mov dword [SLOT_BASE+APPDATA.fpu_state], eax - mov dword [SLOT_BASE+APPDATA.fpu_handler], 0 - mov dword [SLOT_BASE+APPDATA.sse_handler], 0 + xor eax, eax + mov dword [SLOT_BASE+APPDATA.fpu_state], fpu_data + mov dword [SLOT_BASE+APPDATA.fpu_handler], eax + mov dword [SLOT_BASE+APPDATA.sse_handler], eax ; name for OS/IDLE process @@ -680,9 +671,8 @@ no_lib_load: cld rep movsd - mov dword [SLOT_BASE+256+APPDATA.fpu_handler], 0 - mov dword [SLOT_BASE+256+APPDATA.sse_handler], 0 - mov dword [SLOT_BASE+256+APPDATA.cursor], ebx + mov dword [SLOT_BASE+256+APPDATA.fpu_handler], eax + mov dword [SLOT_BASE+256+APPDATA.sse_handler], eax mov ebx, SLOT_BASE+256+APP_OBJ_OFFSET mov dword [SLOT_BASE+256+APPDATA.fd_obj], ebx @@ -766,19 +756,13 @@ no_lib_load: ; LOAD FIRST APPLICATION cli + +if 0 cmp byte [BOOT_VAR+0x9030],1 jne no_load_vrr_m -; mov ebp, vrr_m -; xor ebx, ebx -; xor edx, edx -; call fs_execute -; cmp eax,2 ; if vrr_m app found (PID=2) -; je first_app_found - - stdcall kernel_alloc, 0x100 - push eax + push eax mov ebx,eax stdcall full_file_name,vrr_m,eax mov ebp, eax @@ -790,21 +774,14 @@ no_lib_load: push eax stdcall kernel_free, ebx pop eax + cmp eax,2 ; if vrr_m app found (PID=2) je first_app_found no_load_vrr_m: -; mov ebp, firstapp -; xor ebx, ebx -; xor edx, edx -; call fs_execute -; cmp eax,2 ; continue if a process has been loaded -; je first_app_found -; mov eax, 0xDEADBEEF ; otherwise halt -; hlt stdcall kernel_alloc, 0x100 - push eax + push eax mov ebx,eax stdcall full_file_name,firstapp,eax mov ebp, eax @@ -820,8 +797,44 @@ no_load_vrr_m: mov eax, 0xDEADBEEF ; otherwise halt hlt +first_app_found: + +else + sub esp, 0x100 + + cmp byte [BOOT_VAR+0x9030],1 + jne no_load_vrr_m + + mov ebp, esp + stdcall full_file_name,vrr_m,ebp + + xor ebx, ebx + xor edx, edx + call fs_execute + + cmp eax,2 ; if vrr_m app found (PID=2) + je first_app_found + +no_load_vrr_m: + + mov ebp, esp + stdcall full_file_name,firstapp,ebp + + xor ebx, ebx + xor edx, edx + call fs_execute + + cmp eax,2 ; continue if a process has been loaded + je first_app_found + + mov eax, 0xDEADBEEF ; otherwise halt + hlt first_app_found: + + add esp, 0x100 + +end if cli ;mov [TASK_COUNT],dword 2 @@ -2423,8 +2436,8 @@ sys_background: cmp eax,2 ; SET PIXEL jnz nosb2 - mov edx,[mem_BACKGROUND] - cmp edx,ebx + mov edx,[mem_BACKGROUND] + cmp edx,ebx jbe nosb2 mov edx,[ebx] and edx,0xFF000000 ;255*256*256*256 @@ -3446,10 +3459,10 @@ checkmisc: cmp [ctrl_alt_del], 1 jne nocpustart - - + + stdcall kernel_alloc, 0x100 - push eax + push eax mov ebx,eax stdcall full_file_name,cpustring,eax mov ebp, eax @@ -3462,7 +3475,7 @@ checkmisc: push eax stdcall kernel_free, ebx pop eax - + mov [ctrl_alt_del], 0 nocpustart: