From 7ef2a89c7909bde3c63c9eed65dcb91ab743c5bc Mon Sep 17 00:00:00 2001 From: Nasarus Date: Mon, 11 Oct 2010 19:36:46 +0000 Subject: [PATCH] cObj program added (author: Albom) git-svn-id: svn://kolibrios.org@1655 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/build_all.bat | 1 + programs/develop/cObj/trunk/build_en.bat | 5 + programs/develop/cObj/trunk/build_ru.bat | 5 + programs/develop/cObj/trunk/cObj.asm | 148 +++++++++++++++++++++++ 4 files changed, 159 insertions(+) create mode 100644 programs/develop/cObj/trunk/build_en.bat create mode 100644 programs/develop/cObj/trunk/build_ru.bat create mode 100644 programs/develop/cObj/trunk/cObj.asm diff --git a/programs/build_all.bat b/programs/build_all.bat index 618e518a05..ffb05332ae 100644 --- a/programs/build_all.bat +++ b/programs/build_all.bat @@ -96,6 +96,7 @@ fasm develop\mtdbg\mtdbg.asm %BIN%\develop\mtdbg rem fasm develop\param\trunk\param.asm param fasm develop\scancode\trunk\scancode.asm %BIN%\develop\scancode fasm develop\tinypad\trunk\tinypad.asm %BIN%\tinypad +fasm develop\cObj\trunk\cObj.asm %BIN%\develop\cObj echo * echo Building systems libraries diff --git a/programs/develop/cObj/trunk/build_en.bat b/programs/develop/cObj/trunk/build_en.bat new file mode 100644 index 0000000000..f7997d89dd --- /dev/null +++ b/programs/develop/cObj/trunk/build_en.bat @@ -0,0 +1,5 @@ +@echo lang fix en >lang.inc +@fasm cObj.asm cObj +@kpack cObj +@erase lang.inc +@pause \ No newline at end of file diff --git a/programs/develop/cObj/trunk/build_ru.bat b/programs/develop/cObj/trunk/build_ru.bat new file mode 100644 index 0000000000..38a9a08375 --- /dev/null +++ b/programs/develop/cObj/trunk/build_ru.bat @@ -0,0 +1,5 @@ +@echo lang fix ru >lang.inc +@fasm cObj.asm cObj +@kpack cObj +@erase lang.inc +@pause \ No newline at end of file diff --git a/programs/develop/cObj/trunk/cObj.asm b/programs/develop/cObj/trunk/cObj.asm new file mode 100644 index 0000000000..ab1eae3e9f --- /dev/null +++ b/programs/develop/cObj/trunk/cObj.asm @@ -0,0 +1,148 @@ + +use32 +org 0 +db 'MENUET01' +dd 1 +dd _start +dd _end +dd _memory +dd _stack +dd _param +dd 0 + +;========================================= + +_start: + +mov ah, byte [_param] +test ah, ah +jz _exit + +call console_lib_init + +push cobj_caption +push -1 +push -1 +push -1 +push -1 +call [con_init] + +mov eax, 68 +mov ebx, 19 +mov ecx, _param +int 0x40 +test eax, eax +jz _exit_and_close_console + +mov edx, eax + + +_main_loop: + +cmp dword [edx], 0 +je _exit_and_close_console + +push dword [edx] +push specification +call [con_printf] +add esp, 8 + +add edx, 8 + +jmp _main_loop + +_exit_and_close_console: + +push 0 +call [con_exit] + +_exit: +mov eax, -1 +int 0x40 + + +;========================================= + +console_lib_init: + +; load DLL + mov eax, 68 + mov ebx, 19 + mov ecx, console_lib_name + int 0x40 + test eax, eax + jz _exit + +; initialize import + mov edx, eax + mov esi, console_lib_import +import_loop: + lodsd + test eax, eax + jz import_done + push edx +import_find: + mov ebx, [edx] + test ebx, ebx + jz _exit;import_not_found + push eax +@@: + mov cl, [eax] + cmp cl, [ebx] + jnz import_find_next + test cl, cl + jz import_found + inc eax + inc ebx + jmp @b +import_find_next: + pop eax + add edx, 8 + jmp import_find +import_found: + pop eax + mov eax, [edx+4] + mov [esi-4], eax + pop edx + jmp import_loop +import_done: + +ret + +;========================================= + +console_lib_name db '/sys/lib/console.obj',0 + +align 4 +console_lib_import: +dll_start dd aStart +con_init dd aConInit +con_exit dd aConExit +con_printf dd aCon_printf + dd 0 + +aStart db 'START',0 +aConInit db 'con_init',0 +aConExit db 'con_exit',0 +aCon_printf db 'con_printf',0 + + +;========================================= + +cobj_caption db 'cObj v0.2 by Albom',0 +specification db '%s',13,10,0 + +;========================================= + +_param: +db 0 +rb 256 + +_end: + +align 32 +rb 2048 +_stack: +_memory: + +;========================================= \ No newline at end of file