Rev 3906 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
836 | diamond | 1 | use32 |
2 | db 'MENUET01' |
||
3 | dd 1 |
||
4 | dd start |
||
5 | dd i_end |
||
6 | dd mem |
||
7 | dd mem |
||
8 | dd 0 |
||
9 | dd 0 |
||
10 | |||
11 | REQ_DLL_VER = 2 |
||
12 | DLL_ENTRY = 1 |
||
13 | |||
14 | start: |
||
15 | ; First 3 steps are intended to load/init console DLL |
||
16 | ; and are identical for all console programs |
||
17 | |||
18 | ; load DLL |
||
19 | mov eax, 68 |
||
20 | mov ebx, 19 |
||
21 | mov ecx, dll_name |
||
22 | int 0x40 |
||
23 | test eax, eax |
||
24 | jz exit |
||
25 | |||
26 | ; initialize import |
||
27 | mov edx, eax |
||
28 | mov esi, myimport |
||
29 | import_loop: |
||
30 | lodsd |
||
31 | test eax, eax |
||
32 | jz import_done |
||
33 | push edx |
||
34 | import_find: |
||
35 | mov ebx, [edx] |
||
36 | test ebx, ebx |
||
37 | jz exit;import_not_found |
||
38 | push eax |
||
39 | @@: |
||
40 | mov cl, [eax] |
||
41 | cmp cl, [ebx] |
||
42 | jnz import_find_next |
||
43 | test cl, cl |
||
44 | jz import_found |
||
45 | inc eax |
||
46 | inc ebx |
||
47 | jmp @b |
||
48 | import_find_next: |
||
49 | pop eax |
||
50 | add edx, 8 |
||
51 | jmp import_find |
||
52 | import_found: |
||
53 | pop eax |
||
54 | mov eax, [edx+4] |
||
55 | mov [esi-4], eax |
||
56 | pop edx |
||
57 | jmp import_loop |
||
58 | import_done: |
||
59 | |||
60 | ; check version |
||
61 | cmp word [dll_ver], REQ_DLL_VER |
||
62 | jb exit |
||
63 | cmp word [dll_ver+2], REQ_DLL_VER |
||
64 | ja exit |
||
65 | push DLL_ENTRY |
||
66 | call [dll_start] |
||
67 | |||
68 | ; yes! Now do some work (say helloworld in this case). |
||
69 | push caption |
||
70 | push -1 |
||
71 | push -1 |
||
72 | push -1 |
||
73 | push -1 |
||
74 | call [con_init] |
||
75 | push aHelloWorld |
||
76 | call [con_write_asciiz] |
||
77 | push 0 |
||
78 | call [con_exit] |
||
79 | exit: |
||
80 | or eax, -1 |
||
81 | int 0x40 |
||
82 | |||
83 | dll_name db '/sys/lib/console.obj',0 |
||
84 | caption db 'Console test',0 |
||
85 | aHelloWorld db 'Hello, World!',10,0 |
||
86 | |||
87 | align 4 |
||
88 | myimport: |
||
89 | dll_start dd aStart |
||
90 | dll_ver dd aVersion |
||
91 | con_init dd aConInit |
||
92 | con_write_asciiz dd aConWriteAsciiz |
||
93 | con_exit dd aConExit |
||
94 | dd 0 |
||
95 | |||
96 | aStart db 'START',0 |
||
97 | aVersion db 'version',0 |
||
98 | aConInit db 'con_init',0 |
||
99 | aConWriteAsciiz db 'con_write_asciiz',0 |
||
100 | aConExit db 'con_exit',0 |
||
101 | |||
102 | i_end: |
||
103 | |||
104 | align 4 |
||
105 | rb 2048 ; stack |
||
106 | mem: |