wok view linld/stuff/src/ISOCRTL.ASM @ rev 23864
syslinux/isoboot.s: accept user args (again)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Fri Jun 19 17:01:11 2020 +0000 (2020-06-19) |
parents | c04335df099f |
children | 9096d6788292 |
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 ends _DATA
20 segment _BSS byte public use16 'BSS'
22 include "isostate.inc"
24 public _isostate
25 _isostate isostate <?>
26 ; org $-7
28 ends _BSS
30 segment _TEXT byte public use16 'CODE'
32 global fold:near
33 fold:
34 org 0EF00h
35 global unfold:near
36 unfold:
37 jmp iso_open
38 extrn @isoreaddir$qv
39 dw @isoreaddir$qv
40 jmp @readmenu$qv
42 push dx
43 call readfd
44 push ds
45 pop es
46 mov di,128h ; TABLE
47 mov ax,offset iso_open_hack
48 stosw
49 mov ax,offset iso_read_hack
50 stosw
51 mov ax,offset iso_lseek_hack
52 stosw
53 mov ax,offset iso_close_hack
54 stosw
55 mov ax,offset iso_cleanup_hack
56 stosw
57 global @_cpuhaslm$qv:near
58 @_cpuhaslm$qv:
59 mov ax,[132h]
60 and al,20h
61 ret
63 iso_open_hack:
64 pop ax
65 extrn @_isoopen$qv:near
66 cmp [byte bx],'!'
67 je @readmenu$qv
68 xchg ax,bx
69 global iso_open:near
70 iso_open:
71 mov [_isostate.filename2open],ax
72 call @_isoopen$qv
73 cmp al,1
74 cmc
75 push bx
76 iso_close_hack:
77 pop bx
78 ret
81 macro curseek
82 push cx
83 xor cx,cx
84 xor dx,dx
85 mov ax,4201h
86 call dosfd ; lseek(,0L,SEEK_CUR)
87 call @doseek2
88 ifndef NO386
89 push dx
90 push ax
91 pop eax
92 endif
93 pop cx
94 endm
96 ;***************************************************************
97 ;_fastcall void readmenu(void);
98 ;***************************************************************
99 global @readmenu$qv:near
100 proc @readmenu$qv near
102 mov dx,18
103 xor cx,cx
104 call lseekset
105 mov dx,offset _isostate.filemod
106 mov cx,10
107 call readfd ; // read x->filemod + x->fileofs & x->filesize
108 mov bx,offset _isostate.fileofs
109 ; x->fileofs = 0x7FF0 - (x->filesize &= 0xFFFF);
110 mov ax,7FF0h
111 cwd
112 mov [word bx+6],dx
113 sub ax,[bx+4]
114 mov [word bx+2],dx
115 mov [bx],ax
116 ; //magic = x->filemod;
118 endp @readmenu$qv
120 ;***************************************************************
121 ;_fastcall void isolseek(bx:const unsigned long *offset);
122 ;***************************************************************
123 global @isolseek$qpxul:near
124 proc @isolseek$qpxul near
126 isolseek:
127 mov dx,[bx]
128 mov cx,[bx+2]
129 lseekset:
130 mov ax,4200h ; bx=fd cx:dx=offset al=whence
131 dosfd:
132 mov bx,[_isostate.fd]
133 dos:
134 int 21h
135 failifc:
136 jnc @@dosok
137 fail:
138 sbb ax,ax
139 cwd
140 @@dosok:
141 ret
143 endp @isolseek$qpxul
145 ;***************************************************************
146 ;_fastcall int isoreadsector(bx:const unsigned long *offset);
147 ;***************************************************************
148 global @isoreadsector$qpxul:near
149 proc @isoreadsector$qpxul near
151 call isolseek
152 jc fail
153 mov cx,2560
154 mov dx,offset _isostate.buffer
155 global readfd:near
156 readfd:
157 mov ah,3Fh
158 jmp dosfd
160 endp @isoreadsector$qpxul
162 ;***************************************************************
163 ;_fastcall int strhead(bx:const char* a, ax:const char* b);
164 ;***************************************************************
165 global @strhead$qpxzct1:near
166 proc @strhead$qpxzct1 near
168 @@loop:
169 xchg ax,bx
170 mov cl,[bx] ; cl = *b++
171 inc bx
172 or cl,cl ; clear C
173 jz failifc ; return 0
174 xchg ax,bx
175 xor cl,[bx] ; cl -= *a++
176 inc bx
177 and cl,0dfh ; case insensitive
178 jne fail ; return -1
179 jmp @@loop
181 endp @strhead$qpxzct1
183 ;***************************************************************
184 ;_fastcall int strcmp(bx:const char* a, ax:const char* b);
185 ;***************************************************************
186 global @strcmp$qpxzct1:near
187 proc @strcmp$qpxzct1 near
189 push si
190 xchg ax,si
191 dec bx
192 @@lp:
193 inc bx
194 lodsb
195 sub al,[bx]
196 jnz @@out
197 or al,[bx]
198 jnz @@lp
199 @@out:
200 cbw
201 pop si
202 ret
204 endp @strcmp$qpxzct1
206 iso_read_hack:
207 ifdef NO386
208 push dx
209 curseek
210 mov bx,[word _isostate.filesize]
211 sub bx,ax
212 mov ax,[(word _isostate.filesize)+2]
213 sbb ax,dx
214 ja @@cxok
215 je @@rem
216 xor cx,cx
217 @@rem:
218 cmp bx,cx
219 ja @@cxok
220 mov cx,bx
221 @@cxok:
222 pop dx
223 else
224 p386
225 push edx
226 curseek
227 mov edx,[_isostate.filesize]
228 sub edx,eax
229 jnb @@rem
230 xor cx,cx
231 @@rem:
232 movzx eax,cx
233 cmp edx,eax
234 ja @@cxok
235 mov cx,dx
236 @@cxok:
237 pop edx
238 endif
239 or cx,cx
240 pop bx
241 jmp readfd
243 iso_lseek_hack:
244 xchg ax,bx
245 pop bx
246 ifdef SEEK_CUR
247 cmp al,1 ; current
248 jne @@nocurrent
249 call dosfd ; lseek(,0L,SEEK_CUR)
250 jmp @doseek2
251 @nocurrent:
252 endif
253 add dx,[word _isostate.fileofs]
254 adc cx,[(word _isostate.fileofs)+2]
255 cmp al,0 ; start
256 je @@doseek
257 add dx,[word _isostate.filesize]
258 adc cx,[(word _isostate.filesize)+2]
259 @@doseek:
260 call lseekset ; lseek(,0L,SEEK_SET)
261 @doseek2:
262 sub ax,[word _isostate.fileofs]
263 sbb dx,[(word _isostate.fileofs)+2]
264 ret
266 iso_cleanup_hack:
267 mov ah,3Eh ; close file
268 jmp dosfd
269 ifdef NO386
270 global N_LXLSH@ES:near
271 N_LXLSH@ES:
272 mov dx,es
273 global N_LXLSH@:near
274 N_LXLSH@:
275 mov ch,0
276 @@lp:
277 shl ax,1
278 rcl dx,1
279 loop @@lp
280 ret
281 endif
283 ends _TEXT
285 end