diff --git a/programs/system/launcher/trunk/build_en.bat b/programs/system/launcher/trunk/build_en.bat index 46ba2dfbd..6297cd15d 100644 --- a/programs/system/launcher/trunk/build_en.bat +++ b/programs/system/launcher/trunk/build_en.bat @@ -1,5 +1,6 @@ @erase lang.inc @echo lang fix en >lang.inc @fasm launcher.asm launcher +@kpack launcher @erase lang.inc @pause \ No newline at end of file diff --git a/programs/system/launcher/trunk/build_ru.bat b/programs/system/launcher/trunk/build_ru.bat index 3f93ac66c..a0b1722da 100644 --- a/programs/system/launcher/trunk/build_ru.bat +++ b/programs/system/launcher/trunk/build_ru.bat @@ -1,5 +1,6 @@ @erase lang.inc @echo lang fix ru >lang.inc @fasm launcher.asm launcher +@kpack launcher @erase lang.inc @pause \ No newline at end of file diff --git a/programs/system/launcher/trunk/launcher.asm b/programs/system/launcher/trunk/launcher.asm index ee4916ef0..ee9e8159d 100644 --- a/programs/system/launcher/trunk/launcher.asm +++ b/programs/system/launcher/trunk/launcher.asm @@ -1,259 +1,294 @@ +;----------------------------------------------------------------------------- ; -; LAUNCHER - АВТОЗАПУСК ПРОГРАММ -; Код программы совсем не оптимизирован, но очень прост для понимания. -; Этот лаунчер грузит информацию о программах для запуска из файла -; AUTORUN.DAT. Формат очень прост и в комментариях не нуждается. +; LAUNCHER - startup of programs ; -; Компилируйте с помощью FASM 1.52 и выше +; Compile with FASM 1.52 or newer ; +;----------------------------------------------------------------------------- +; last update: 02/03/2014 +; changed by: Marat Zakiyanov aka Mario79, aka Mario +; changes: Reducing the consumption of RAM, 4 KB instead of 32 KB. +; Output to BOARD information about running applications. +; Cleaning of the source code. +; notice: Only 2 KB of memory for AUTORUN.DAT - be careful! +;----------------------------------------------------------------------------- + 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 stack_top ; esp + dd 0x0 ; I_Param + dd 0x0 ; I_Icon +;----------------------------------------------------------------------------- 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 0x8000 ; memory for app - dd 0x8000 ; esp - dd 0x0 , 0x0 ; I_Param , I_Icon - -;include "DEBUG.INC" - +define __DEBUG__ 1 +define __DEBUG_LEVEL__ 1 +include "../../../debug-fdo.inc" +;----------------------------------------------------------------------------- START: ; start of execution - -; mov eax, 5 -; mov ebx, 10 -; mcall - -; mcall 18,15 - - mov eax, 70 ; load AUTORUN.DAT - mov ebx, autorun_dat_info - mcall - add ebx, file_data - mov [fileend], ebx - + mcall 70,autorun_dat_info ; load AUTORUN.DAT + add ebx,file_data + mov [fileend],ebx +;----------------------------------------------------------------------------- ; this cycle does not contain an obvious exit condition, ; but auxiliary procedures (like "get_string") will exit ; at EOF - start_program: - call skip_spaces - cmp al,'#' - jz skip_this_string - call clear_strings - mov edi, program - call get_string - mov edi, parameters - call get_string - call get_number -;dps <"STARTING A PROGRAM",13,10> - call run_program - skip_this_string: - call next_line - jmp start_program - - exit: - or eax, -1 - mcall - - - run_program: ; time to delay in eax - push eax - mcall 70, start_info - pop ebx - +start_program: + call skip_spaces + cmp al,byte '#' + jz skip_this_string + call clear_strings + mov edi,program + call get_string + mov edi,parameters + call get_string + call get_number + call run_program +;-------------------------------------- +skip_this_string: + call next_line + jmp start_program +;----------------------------------------------------------------------------- +exit: + or eax,-1 + mcall +;----------------------------------------------------------------------------- +run_program: ; time to delay in eax + DEBUGF 1, "Launch: %s Parameter: %s\n",program,parameters + push eax + mcall 70,start_info + pop ebx ; if delay is negative, wait for termination ; of the spawned process - test ebx, ebx - js must_wait_for_termination + test ebx,ebx + js must_wait_for_termination ; otherwise, simply wait - mov eax, 5 - mcall - ret - must_wait_for_termination: - mov esi, eax ; save slot for the future + mcall 5 + ret +;----------------------------------------------------------------------------- +must_wait_for_termination: + mov esi,eax ; save slot for the future ; get process slot - mov ecx, eax - mcall 18, 21 + mov ecx,eax + mcall 18,21 ; if an error has occured, exit - test eax, eax - jz child_exited - mov ecx, eax -; wait - wait_for_termination: - mcall 5, 1 - mov ebx, processinfo - mcall 9 - cmp word [ebx+50], 9 ; the slot was freed? - jz child_exited - cmp dword [ebx+30], esi ; the slot is still occupied by our child? - jz wait_for_termination - child_exited: - ret + test eax,eax + jz child_exited - clear_strings: ; clears buffers - pushad + mov ecx,eax +;-------------------------------------- +wait_for_termination: + mcall 5,1 + mov ebx, processinfo + mcall 9 + cmp [ebx+50],word 9 ; the slot was freed? + jz child_exited - mov ecx, 60 - mov edi, program - xor al, al ;mov al, ' ' - rep stosb + cmp [ebx+30],dword esi ; the slot is still occupied by our child? + jz wait_for_termination +;-------------------------------------- +child_exited: + ret +;----------------------------------------------------------------------------- +clear_strings: ; clears buffers + pushad + mov ecx,60+1 + mov edi,program + xor al,al + rep stosb + mov ecx,60+1 + mov edi,parameters + rep stosb + popad + ret +;----------------------------------------------------------------------------- +get_string: ; pointer to destination buffer in edi + pushad + call skip_spaces + mov esi,[position] + add esi,file_data + cmp [esi],byte '"' + jz .quoted +;-------------------------------------- +.start: + cmp esi,[fileend] + jae exit - mov ecx, 60 - mov edi, parameters - rep stosb + lodsb + cmp al,byte ' ' + jbe .finish - popad - ret + stosb + inc dword [position] + jmp .start +;-------------------------------------- +.finish: + popad + ret +;-------------------------------------- +.quoted: + inc esi + inc dword [position] +;-------------------------------------- +.quoted.start: + cmp esi,[fileend] + jae exit + lodsb + inc dword [position] + cmp al,byte '"' + je .finish - get_string: ; pointer to destination buffer in edi - pushad - call skip_spaces - mov esi, [position] -;dpd esi -;dps <13,10> - add esi, file_data - cmp byte [esi], '"' - jz .quoted - .start: - cmp esi, [fileend] - jae exit - lodsb - cmp al, ' ' - jbe .finish - stosb - inc [position] - jmp .start - .finish: - popad - ret - .quoted: - inc esi - inc [position] - .quoted.start: - cmp esi, [fileend] - jae exit - lodsb - inc [position] - cmp al, '"' - je .finish - stosb - jmp .quoted.start + stosb + jmp .quoted.start +;----------------------------------------------------------------------------- +get_number: + push ebx esi + call skip_spaces + mov esi,[position] + add esi,file_data + xor eax,eax + cmp [esi],byte '-' + jnz @f - - get_number: - push ebx esi - call skip_spaces - mov esi, [position] - add esi, file_data - xor eax, eax - cmp byte [esi], '-' - jnz @f - inc eax - inc esi - inc [position] + inc eax + inc esi + inc dword [position] +;-------------------------------------- @@: - push eax - xor eax, eax - xor ebx, ebx - .start: - cmp esi, [fileend] - jae .finish - lodsb - sub al, '0' - cmp al, 9 - ja .finish - lea ebx,[ebx*4+ebx] - lea ebx,[ebx*2+eax] - inc [position] - jmp .start - .finish: - pop eax - dec eax - jnz @f - neg ebx + push eax + xor eax,eax + xor ebx,ebx +;-------------------------------------- +.start: + cmp esi,[fileend] + jae .finish + + lodsb + sub al,byte '0' + cmp al,9 + ja .finish + + lea ebx,[ebx*4+ebx] + lea ebx,[ebx*2+eax] + inc dword [position] + jmp .start +;-------------------------------------- +.finish: + pop eax + dec eax + jnz @f + + neg ebx +;-------------------------------------- @@: - mov eax, ebx - pop esi ebx - ret + mov eax,ebx + pop esi ebx + ret +;----------------------------------------------------------------------------- +skip_spaces: + push esi + xor eax,eax + mov esi,[position] + add esi,file_data +;-------------------------------------- +.start: + cmp esi,[fileend] + jae .finish + lodsb + cmp al,byte ' ' + ja .finish - skip_spaces: - push esi - xor eax, eax - mov esi, [position] - add esi, file_data - .start: - cmp esi, [fileend] - jae .finish - lodsb - cmp al, ' ' - ja .finish - inc [position] - jmp .start - .finish: -;dps "NOW AL = " -;mov [tmp],al -;mov edx, tmp -;call debug_outstr -;dps <13,10> - pop esi - ret + inc dword [position] + jmp .start +;-------------------------------------- +.finish: + pop esi + ret +;----------------------------------------------------------------------------- +next_line: + mov esi,[position] + add esi,file_data +;-------------------------------------- +.start: + cmp esi,[fileend] + jae exit + lodsb + cmp al,13 + je .finish - next_line: - mov esi, [position] - add esi, file_data - .start: - cmp esi, [fileend] - jae exit - lodsb - cmp al, 13 - je .finish - cmp al, 10 - je .finish - inc [position] - jmp .start - .finish: - inc [position] - cmp esi, [fileend] - jae exit - lodsb - cmp al, 13 - je .finish - cmp al, 10 - je .finish - ret + cmp al,10 + je .finish + inc dword [position] + jmp .start +;-------------------------------------- +.finish: + inc dword [position] + cmp esi,[fileend] + jae exit + lodsb + cmp al,13 + je .finish + cmp al,10 + je .finish + + ret +;----------------------------------------------------------------------------- ; DATA: - position dd 0 ; position in file - - autorun_dat_info: ; AUTORUN.DAT - .mode dd 0 ; read file - .start_block dd 0 ; block to read - dd 0 - .blocks dd 16*512 ; 16*512 bytes max - .address dd file_data - db "/SYS/SETTINGS/AUTORUN.DAT",0 - - start_info: - .mode dd 7 - dd 0 - .params dd parameters - dd 0 - dd 0 - .path: ;       - +;----------------------------------------------------------------------------- +include_debug_strings +;----------------------------------------------------------------------------- +autorun_dat_info: ; AUTORUN.DAT + .mode dd 0 ; read file + .start_block dd 0 ; block to read + dd 0 + .blocks dd 4*512 ; 2 Kb max for AUTORUN.DAT + .address dd file_data + db "/SYS/SETTINGS/AUTORUN.DAT",0 +;----------------------------------------------------------------------------- +start_info: + .mode dd 7 + dd 0 + .params dd parameters + dd 0 + dd 0 + .path: +;----------------------------------------------------------------------------- +IM_END: +;----------------------------------------------------------------------------- +align 4 +processinfo: +;----------------------------------------------------------------------------- +program: + rb 61 ; 60 + [0] char +;----------------------------------------------------------------------------- +parameters: + rb 61 +;----------------------------------------------------------------------------- + rb 1024-61*2 +;----------------------------------------------------------------------------- +position: + rd 1 ; position in file +;----------------------------------------------------------------------------- +fileend: + rd 1 +;----------------------------------------------------------------------------- +align 4 +file_data: + rb 4*512 ; 2 Kb for AUTORUN.DAT +;----------------------------------------------------------------------------- +align 4 + rb 256 +stack_top: +;----------------------------------------------------------------------------- I_END: - - program rb 61 ; 60 + [0] char - parameters rb 61 - - processinfo rb 1024 - fileend dd ? - - file_data rb 16*512 +;-----------------------------------------------------------------------------