wok view linld/stuff/src/ISOCRTL.ASM @ rev 23983

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