wok view linld/stuff/src/_ISOBEG.ASM @ rev 23809

linld: add isoboot (again)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun May 24 16:43:25 2020 +0000 (2020-05-24)
parents
children e93fa0cecd8a
line source
1 ;***************************************************************
2 ;****** This file is distributed under GPL
3 ;***************************************************************
4 ideal
5 %PAGESIZE 1000
6 %crefref
7 %noincl
8 %nomacs
9 p8086
11 group DGROUP _TEXT,_DATA,_BSS
12 assume cs:DGROUP,ds:DGROUP
14 segment _TEXT byte public use16 'CODE'
15 ends _TEXT
17 segment _DATA byte public use16 'DATA'
18 global _data_start:byte
19 label _data_start byte
20 ends _DATA
22 segment _BSS byte public use16 'BSS'
24 global _bss_start:byte
25 label _bss_start byte
26 utoabuf db 6 dup(?)
28 include "isostate.inc"
30 extrn _isostate:isostate
32 ends _BSS
34 segment _TEXT byte public use16 'CODE'
36 org 100h
37 global _text_start:byte
38 label _text_start byte
40 extrn fold
41 extrn unfold
42 mov si,offset fold
43 mov di,offset unfold
44 mov ch,4
45 cld
46 rep
47 movsw
49 ;***************************************************************
50 ; clear bss
51 ;***************************************************************
53 mov si,offset _bss_start
54 clearbss:
55 mov [byte si],cl ; clear bss + heap
56 inc si
57 jne clearbss
59 ;***************************************************************
60 ; build arg
61 ;***************************************************************
63 mov bx,endbzimage-bzimage
64 mov si,80h
65 mov di,si
66 lodsb
67 add [di],bl
68 cbw
69 mov bp,-1
70 skipspace:
71 inc bp
72 cmp [byte bp+si]," "
73 je skipspace
74 xchg ax,cx
75 add si,cx
76 dec si
77 lea di,[bx+si]
78 mov [di+1],bh
79 sub cx,bp
80 std
81 rep
82 movsb
83 push di
84 mov si,offset endbzimage-1
85 mov cl,bl
86 rep
87 movsb
88 pop si
89 inc si
90 cld
92 ifdef LONG_FILENAME
93 mov ax,716Ch
94 xor bx,bx ; R/O
95 ;xor cx,cx ; attributes
96 cwd ; action = open
97 stc
98 int 21h
99 jnc opened
100 endif
101 mov ax,3d00h ; read-only+compatibility
102 ;mov cl,0 ; attribute mask
103 mov dx,si
104 int 21h
105 jnc opened
107 _abort:
108 mov dx,offset stopmsg
109 mov ah,9
110 int 21h
111 int 20h
112 opened:
113 mov [_isostate.fd],ax
114 mov ax,offset bootdir
115 extrn iso_open:near
116 call iso_open
117 jc_abort:
118 jc _abort
120 ;***************************************************************
122 ; patch magic
123 extrn @readmenu$qv:near
124 call @readmenu$qv
125 mov ax,[_isostate.filemod]
126 mov bx,10
127 xor cx,cx
128 @@loop1:
129 xor dx,dx
130 div bx ; DX:AX = n%10:n/10
131 push dx ; DL = n%10
132 inc cx
133 or ax,ax
134 jnz @@loop1
135 push ds
136 pop es
137 lea di,[bp+magic-bzimage+81h]
138 @@loop2:
139 pop ax
140 add al,'0'
141 stosb
142 loop @@loop2
144 ; patch initrd
145 cwd
146 or [_isostate.curdirsize],-1
147 jmp patchtest
148 found:
149 inc dh
150 patchtest:
151 push dx
152 extrn @isoreaddir$qv:near
153 call @isoreaddir$qv
154 pop dx
155 push ds
156 pop es
157 inc ax
158 jne patchlp
159 cmp dx,100h
160 je initrddone
161 lea di,[bp+rootfs-bzimage+87h]
162 or dh,dh
163 je modify
164 add di,4
165 mov si,offset rootfs
166 mov cx,3
167 rep
168 movsw
169 modify:
170 xchg ax,dx
171 stosb
172 mov si,offset dotgz
173 mov cl,5
174 rep
175 movsb
176 initrddone:
178 ;***************************************************************
180 mov ax,offset linld
181 call iso_open
182 jc jc_abort
183 mov cx,[word _isostate.filesize]
184 mov dx,100h
185 jmp near unfold
186 patchlp:
187 mov si,[_isostate.filename]
188 mov di,offset rootfs
189 mov cx,9
190 rep
191 cmpsb
192 jcxz found
193 cmp cl,3
194 ja patchtest
195 dec si
196 cmp dl,[si]
197 ja patchtest
198 mov dl,[si]
199 jmp patchtest
201 stopmsg:
202 db "This program cannot be run in DOS mode$"
203 bootdir:
204 db "/boot",0
205 linld:
206 db "linld.com",0
207 bzimage:
208 db "-f "
209 ;db "image=boot\bzImage "
210 db "initrd="
211 rootfs:
212 db "rootfs"
213 dotgz:
214 db ".gz,! "
215 ; ".gz,rootfs4.gz,! "
216 ;db "rw "
217 db "autologin rdinit=/init.exe mode=menu magic="
218 magic:
219 db "0 bootfrom="
220 ; "65535 bootfrom="
221 endbzimage:
224 ;***************************************************************
226 ends _TEXT
229 end _text_start
231 ;###### END OF FILE ############################################