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