forked from KolibriOS/kolibrios
console: example testcon.asm use macros
git-svn-id: svn://kolibrios.org@3906 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
682164bace
commit
78710b1c30
@ -8,62 +8,20 @@ use32
|
|||||||
dd 0
|
dd 0
|
||||||
dd 0
|
dd 0
|
||||||
|
|
||||||
REQ_DLL_VER = 2
|
; useful includes
|
||||||
DLL_ENTRY = 1
|
include '../../../../macros.inc'
|
||||||
|
purge mov,add,sub
|
||||||
|
include '../../../../proc32.inc'
|
||||||
|
include '../../../../dll.inc'
|
||||||
|
|
||||||
start:
|
start:
|
||||||
; First 3 steps are intended to load/init console DLL
|
; First 3 steps are intended to load/init console DLL
|
||||||
; and are identical for all console programs
|
; and are identical for all console programs
|
||||||
|
|
||||||
; load DLL
|
; load DLL
|
||||||
mov eax, 68
|
stdcall dll.Load, @IMPORT
|
||||||
mov ebx, 19
|
|
||||||
mov ecx, dll_name
|
|
||||||
int 0x40
|
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz exit
|
jnz exit
|
||||||
|
|
||||||
; initialize import
|
|
||||||
mov edx, eax
|
|
||||||
mov esi, myimport
|
|
||||||
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:
|
|
||||||
|
|
||||||
; check version
|
|
||||||
cmp word [dll_ver], REQ_DLL_VER
|
|
||||||
jb exit
|
|
||||||
cmp word [dll_ver+2], REQ_DLL_VER
|
|
||||||
ja exit
|
|
||||||
push DLL_ENTRY
|
|
||||||
call [dll_start]
|
|
||||||
|
|
||||||
; yes! Now do some work (say helloworld in this case).
|
; yes! Now do some work (say helloworld in this case).
|
||||||
push caption
|
push caption
|
||||||
@ -80,27 +38,21 @@ exit:
|
|||||||
or eax, -1
|
or eax, -1
|
||||||
int 0x40
|
int 0x40
|
||||||
|
|
||||||
dll_name db '/sys/lib/console.obj',0
|
caption db 'Console test',0
|
||||||
caption db 'Console test',0
|
aHelloWorld db 'Hello, World!',10,0
|
||||||
aHelloWorld db 'Hello, World!',10,0
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
myimport:
|
@IMPORT:
|
||||||
dll_start dd aStart
|
library console, 'console.obj'
|
||||||
dll_ver dd aVersion
|
import console, \
|
||||||
con_init dd aConInit
|
con_start, 'START', \
|
||||||
con_write_asciiz dd aConWriteAsciiz
|
con_init, 'con_init', \
|
||||||
con_exit dd aConExit
|
con_write_asciiz, 'con_write_asciiz', \
|
||||||
dd 0
|
con_exit, 'con_exit', \
|
||||||
|
con_gets, 'con_gets'
|
||||||
aStart db 'START',0
|
|
||||||
aVersion db 'version',0
|
|
||||||
aConInit db 'con_init',0
|
|
||||||
aConWriteAsciiz db 'con_write_asciiz',0
|
|
||||||
aConExit db 'con_exit',0
|
|
||||||
|
|
||||||
i_end:
|
i_end:
|
||||||
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
rb 2048 ; stack
|
rb 2048 ; stack
|
||||||
mem:
|
mem:
|
||||||
|
Loading…
Reference in New Issue
Block a user