wok-6.x rev 23984
linld: fix bootiso/strhead
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Wed Nov 25 20:41:41 2020 +0000 (2020-11-25) |
parents | fc88d0826de4 |
children | 555bcdab610b |
files | linld/stuff/src/CRTL.ASM linld/stuff/src/ISO9660.CPP linld/stuff/src/ISOCRTL.ASM linld/stuff/src/JUMP.ASM linld/stuff/src/pipehole.awk |
line diff
1.1 --- a/linld/stuff/src/CRTL.ASM Tue Nov 24 08:47:45 2020 +0000 1.2 +++ b/linld/stuff/src/CRTL.ASM Wed Nov 25 20:41:41 2020 +0000 1.3 @@ -135,20 +135,17 @@ 1.4 global @strcmp$qpxzct1:near 1.5 proc @strcmp$qpxzct1 near 1.6 1.7 - push si 1.8 - xchg ax,si 1.9 - dec bx 1.10 -@@lp: 1.11 - inc bx 1.12 - lodsb 1.13 - sub al,[bx] 1.14 - jnz @@out 1.15 - or al,[bx] 1.16 - jnz @@lp 1.17 -@@out: 1.18 - cbw 1.19 - pop si 1.20 - ret 1.21 +@@loop: 1.22 + xchg ax,bx 1.23 + mov cl,[bx] ; cl = *b++ 1.24 + inc bx 1.25 + xchg ax,bx 1.26 + cmp cl,[bx] ; cl ?= *a++ 1.27 + jnz fail ; return -1 1.28 + inc bx 1.29 + or cl,cl ; clear C 1.30 + jz failifc ; return 0 1.31 + jmp @@loop 1.32 1.33 endp @strcmp$qpxzct1 1.34 endif 1.35 @@ -169,6 +166,7 @@ 1.36 1.37 open: ; open(bx) 1.38 ifdef ISOHOOK 1.39 +;_fastcall int open(bx:const char* name); 1.40 extrn iso_open_hack:word 1.41 call [iso_open_hack] ; or ret 1.42 endif 1.43 @@ -255,6 +253,7 @@ 1.44 mov ah,3Fh 1.45 endif 1.46 ifdef ISOHOOK 1.47 +;_fastcall int read(bx:int fd, dx:void* data, cx:int sz); 1.48 extrn iso_read_hack:word 1.49 call [iso_read_hack] ; or ret 1.50 endif 1.51 @@ -298,6 +297,7 @@ 1.52 sbb cx,cx 1.53 lseekset: 1.54 ifdef ISOHOOK 1.55 +;_fastcall long lseek(ax:int fd, cxdx:unsigned long offset, bl:whence); 1.56 extrn iso_lseek_hack:word 1.57 call [iso_lseek_hack] ; or ret 1.58 endif 1.59 @@ -417,7 +417,7 @@ 1.60 endif 1.61 cmp [byte bx],'|' 1.62 je @@test 1.63 - cmp [byte bx],0 1.64 + cmp [byte bx],dh 1.65 je @@test 1.66 mov al,-1 1.67 inc bx 1.68 @@ -425,7 +425,7 @@ 1.69 @@test: 1.70 or al,al ; 1st loop ? 1.71 jns @@testal 1.72 - cmp [byte bx],0 1.73 + cmp [byte bx],dh 1.74 jne @@loop 1.75 @@testal: 1.76 cmp al,'='
2.1 --- a/linld/stuff/src/ISO9660.CPP Tue Nov 24 08:47:45 2020 +0000 2.2 +++ b/linld/stuff/src/ISO9660.CPP Wed Nov 25 20:41:41 2020 +0000 2.3 @@ -12,17 +12,17 @@ 2.4 #endif 2.5 2.6 #ifdef ISOHOOK 2.7 -void isoroot(void) 2.8 +#define isoroot() \ 2.9 +{ \ 2.10 + static const unsigned long root = 16UL * 2048; \ 2.11 + isoreadsector(&root); \ 2.12 + setdirofs(isostate.dirofs, (* (unsigned long *) (isostate.buffer + 0x9E))); \ 2.13 + isostate.dirsize = filesize2dirsize(* (unsigned long *) (isostate.buffer + 0xA6)); \ 2.14 +} 2.15 #else 2.16 int isoroot(void) 2.17 -#endif 2.18 { 2.19 static const unsigned long root = 16UL * 2048; 2.20 -#ifdef ISOHOOK 2.21 - isoreadsector(&root); 2.22 - setdirofs(isostate.dirofs, (* (unsigned long *) (isostate.buffer + 0x9E))); 2.23 - isostate.dirsize = filesize2dirsize(* (unsigned long *) (isostate.buffer + 0xA6)); 2.24 -#else 2.25 if (isoreadsector(&root) == -1 || strhead(isostate.buffer+1,"CD001") == -1) { 2.26 //close(isostate.fd); 2.27 return -1; 2.28 @@ -30,8 +30,8 @@ 2.29 setdirofs(isostate.dirofs, (* (unsigned long *) (isostate.buffer + 0x9E))); 2.30 isostate.dirsize = filesize2dirsize(* (unsigned long *) (isostate.buffer + 0xA6)); 2.31 return 0; 2.32 +} 2.33 #endif 2.34 -} 2.35 2.36 int isoreaddir(void) 2.37 { 2.38 @@ -122,12 +122,7 @@ 2.39 #define _64bits (x->_64bits) 2.40 char *s; 2.41 2.42 -#ifdef ISOHOOK 2.43 - extern int _cpuhaslm(); 2.44 - _64bits = _cpuhaslm(); 2.45 -#else 2.46 _64bits = cpuhaslm(); 2.47 -#endif 2.48 do { 2.49 #ifdef ISOHOOK 2.50 s = (char *) x->filename2open; 2.51 @@ -155,7 +150,7 @@ 2.52 n = "64"; 2.53 i += s - name; // strlen(name); 2.54 } 2.55 - if (strcmp(i, n)) continue; 2.56 + if (strcmp(i, n) == -1) continue; 2.57 #ifndef ISOHOOK 2.58 *s++ = c; 2.59 #endif
3.1 --- a/linld/stuff/src/ISOCRTL.ASM Tue Nov 24 08:47:45 2020 +0000 3.2 +++ b/linld/stuff/src/ISOCRTL.ASM Wed Nov 25 20:41:41 2020 +0000 3.3 @@ -6,7 +6,11 @@ 3.4 %crefref 3.5 %noincl 3.6 %nomacs 3.7 + ifdef NO386 3.8 p8086 3.9 + else 3.10 + p386 3.11 + endif 3.12 3.13 group DGROUP _TEXT,_DATA,_BSS 3.14 assume cs:DGROUP,ds:DGROUP 3.15 @@ -31,7 +35,10 @@ 3.16 3.17 global fold:near 3.18 fold: 3.19 - org 0EF00h 3.20 + org 130h-100h 3.21 + global _cpu_features:dword 3.22 +_cpu_features dd ? 3.23 + org 0F000h-100h 3.24 global unfold:near 3.25 unfold: 3.26 jmp iso_open 3.27 @@ -52,14 +59,24 @@ 3.28 stosw 3.29 mov al,offset iso_close_hack-0F000h 3.30 stosw 3.31 - global @_cpuhaslm$qv:near 3.32 -@_cpuhaslm$qv: 3.33 - mov ax,[130h+3] 3.34 - and al,20h 3.35 + ifdef NO386 3.36 + global N_LXLSH@ES:near 3.37 +N_LXLSH@ES: 3.38 + mov dx,es 3.39 + global N_LXLSH@:near 3.40 +N_LXLSH@: 3.41 + mov ch,0 3.42 +@@lp: 3.43 + shl ax,1 3.44 + rcl dx,1 3.45 + loop @@lp 3.46 + endif 3.47 ret 3.48 3.49 +;*************************************************************** 3.50 +;_fastcall int open(bx:const char* name); 3.51 +;*************************************************************** 3.52 iso_open_hack: 3.53 - pop ax 3.54 extrn @_isoopen$qv:near 3.55 cmp [byte bx],'!' 3.56 je @readmenu$qv 3.57 @@ -70,33 +87,18 @@ 3.58 call @_isoopen$qv 3.59 cmp al,1 3.60 cmc 3.61 - push bx 3.62 iso_close_hack: 3.63 pop bx 3.64 ret 3.65 3.66 3.67 - macro curseek 3.68 - push cx 3.69 - xor cx,cx 3.70 - mov ax,4201h 3.71 - cwd 3.72 - call dosfd ; lseek(,0L,SEEK_CUR) 3.73 - call @doseek2 3.74 - ifndef NO386 3.75 - push dx 3.76 - push ax 3.77 - pop eax 3.78 - endif 3.79 - pop cx 3.80 - endm 3.81 - 3.82 ;*************************************************************** 3.83 ;_fastcall void readmenu(void); 3.84 ;*************************************************************** 3.85 global @readmenu$qv:near 3.86 proc @readmenu$qv near 3.87 3.88 + pop ax 3.89 mov dx,18 3.90 xor cx,cx 3.91 call lseekset 3.92 @@ -131,11 +133,11 @@ 3.93 dos: 3.94 int 21h 3.95 failifc: 3.96 - jnc @@dosok 3.97 + jnc dosok 3.98 fail: 3.99 sbb ax,ax 3.100 cwd 3.101 -@@dosok: 3.102 +dosok: 3.103 ret 3.104 3.105 endp @isolseek$qpxul 3.106 @@ -168,11 +170,12 @@ 3.107 mov cl,[bx] ; cl = *b++ 3.108 inc bx 3.109 or cl,cl ; clear C 3.110 - jz failifc ; return 0 3.111 + jz fail ; return 0 3.112 xchg ax,bx 3.113 xor cl,[bx] ; cl -= *a++ 3.114 inc bx 3.115 - and cl,0dfh ; case insensitive 3.116 + or cl,cl 3.117 + stc 3.118 jne fail ; return -1 3.119 jmp @@loop 3.120 3.121 @@ -184,97 +187,91 @@ 3.122 global @strcmp$qpxzct1:near 3.123 proc @strcmp$qpxzct1 near 3.124 3.125 - push si 3.126 - xchg ax,si 3.127 - dec bx 3.128 -@@lp: 3.129 - inc bx 3.130 - lodsb 3.131 - sub al,[bx] 3.132 - jnz @@out 3.133 - or al,[bx] 3.134 - jnz @@lp 3.135 -@@out: 3.136 - cbw 3.137 - pop si 3.138 - ret 3.139 + call @strhead$qpxzct1 3.140 + jne dosok ; return -1 3.141 + xchg ax,bx 3.142 + cmp cl,[bx] 3.143 + jmp fail ; return 0 or -1 3.144 3.145 endp @strcmp$qpxzct1 3.146 3.147 +;*************************************************************** 3.148 +;_fastcall int read(bx:int fd=isostate.fd, dx:void* data, cx:int sz); 3.149 +;*************************************************************** 3.150 iso_read_hack: 3.151 + push dx 3.152 + push cx 3.153 + xor cx,cx 3.154 + mov ax,4201h 3.155 + cwd 3.156 + ifdef SEEK_CUR 3.157 + call curpos ; bx = _isostate.fileofs 3.158 + else 3.159 + call dosfd ; lseek(,0L,SEEK_CUR) 3.160 + call sub_fileofs ; bx = _isostate.fileofs 3.161 + endif 3.162 ifdef NO386 3.163 + mov cx,[bx+4] ; _isostate.filesize 3.164 + sub cx,ax 3.165 + mov ax,[bx+6] 3.166 + sbb ax,dx 3.167 + pop ax 3.168 + ja @@axok 3.169 + je @@rem 3.170 + xor ax,ax 3.171 +@@rem: 3.172 + cmp cx,ax 3.173 + jb @@cxok 3.174 +@@axok: 3.175 + else 3.176 push dx 3.177 - curseek 3.178 - mov bx,[word _isostate.filesize] 3.179 - sub bx,ax 3.180 - mov ax,[(word _isostate.filesize)+2] 3.181 - sbb ax,dx 3.182 - ja @@cxok 3.183 - je @@rem 3.184 + push ax 3.185 + pop edx 3.186 + mov eax,[bx+4] ; _isostate.filesize 3.187 + sub eax,edx 3.188 + pop cx 3.189 + ja @@rem 3.190 xor cx,cx 3.191 @@rem: 3.192 - cmp bx,cx 3.193 + movzx ecx,cx 3.194 + cmp eax,ecx 3.195 ja @@cxok 3.196 - mov cx,bx 3.197 + endif 3.198 + xchg ax,cx 3.199 @@cxok: 3.200 - pop dx 3.201 - else 3.202 - p386 3.203 - push edx 3.204 - curseek 3.205 - mov edx,[_isostate.filesize] 3.206 - sub edx,eax 3.207 - jnb @@rem 3.208 - xor cx,cx 3.209 -@@rem: 3.210 - movzx eax,cx 3.211 - cmp edx,eax 3.212 - ja @@cxok 3.213 - mov cx,dx 3.214 -@@cxok: 3.215 - pop edx 3.216 - endif 3.217 - or cx,cx 3.218 - pop bx 3.219 + pop dx ; buffer 3.220 + pop bx ; skip last caller 3.221 jmp readfd 3.222 3.223 +;*************************************************************** 3.224 +;_fastcall long lseek(ax:int fd=isostate.fd, cxdx:unsigned long offset, bl:whence); 3.225 +;*************************************************************** 3.226 iso_lseek_hack: 3.227 xchg ax,bx 3.228 - pop bx 3.229 + pop bx ; skip last caller 3.230 ifdef SEEK_CUR 3.231 cmp al,1 ; current 3.232 jne @@nocurrent 3.233 +curpos: 3.234 call dosfd ; lseek(,0L,SEEK_CUR) 3.235 - jmp @doseek2 3.236 -@nocurrent: 3.237 + jmp sub_fileofs 3.238 +@@nocurrent: 3.239 endif 3.240 - add dx,[word _isostate.fileofs] 3.241 - adc cx,[(word _isostate.fileofs)+2] 3.242 + mov bx,offset _isostate.fileofs 3.243 + add dx,[bx] 3.244 + adc cx,[bx+2] 3.245 cmp al,0 ; start 3.246 je @@doseek 3.247 - add dx,[word _isostate.filesize] 3.248 - adc cx,[(word _isostate.filesize)+2] 3.249 + add dx,[bx+4] ; _isostate.filesize 3.250 + adc cx,[bx+6] 3.251 @@doseek: 3.252 call lseekset ; lseek(,0L,SEEK_SET) 3.253 -@doseek2: 3.254 - sub ax,[word _isostate.fileofs] 3.255 - sbb dx,[(word _isostate.fileofs)+2] 3.256 +sub_fileofs: 3.257 + mov bx,offset _isostate.fileofs 3.258 + sub ax,[bx] 3.259 + sbb dx,[bx+2] 3.260 ret 3.261 3.262 - ifdef NO386 3.263 - global N_LXLSH@ES:near 3.264 -N_LXLSH@ES: 3.265 - mov dx,es 3.266 - global N_LXLSH@:near 3.267 -N_LXLSH@: 3.268 - mov ch,0 3.269 -@@lp: 3.270 - shl ax,1 3.271 - rcl dx,1 3.272 - loop @@lp 3.273 - ret 3.274 - endif 3.275 - 3.276 ends _TEXT 3.277 3.278 end
4.1 --- a/linld/stuff/src/JUMP.ASM Tue Nov 24 08:47:45 2020 +0000 4.2 +++ b/linld/stuff/src/JUMP.ASM Wed Nov 25 20:41:41 2020 +0000 4.3 @@ -134,8 +134,11 @@ 4.4 push dx ; size hi 4.5 endif 4.6 push si ; size lo=up to 512k 4.7 - extrn _imgs:dword 4.8 - push [dword _imgs+2] ; src ofs = pm.fallback 4.9 + 4.10 + include "himem.inc" 4.11 + 4.12 + extrn _imgs:image_himem 4.13 + push [_imgs.fallback] ; src ofs = pm.fallback 4.14 4.15 ;in al,70h 4.16 ;or al,80h ; disable NMI
5.1 --- a/linld/stuff/src/pipehole.awk Tue Nov 24 08:47:45 2020 +0000 5.2 +++ b/linld/stuff/src/pipehole.awk Wed Nov 25 20:41:41 2020 +0000 5.3 @@ -315,7 +315,7 @@ 5.4 if (/al,/ || /,al/) sub(/al/,"cl") 5.5 if (/cmp byte ptr \[si\+34\],0/) $0=" or cl,cl" 5.6 if (/jne @@0$/) next 5.7 - if (/jmp @3@58$/) $0=" je @3@58" 5.8 + if (/jmp @.@58$/) sub(/jmp/,"je") 5.9 sub(/mov ax,-1/,"dec ax") 5.10 } 5.11 } # file == "iso9660.cpp" 5.12 @@ -750,6 +750,7 @@ 5.13 /^ call near ptr @isoopen\$/ || 5.14 /^ call near ptr @isoreadsector\$/ || 5.15 /^ call near ptr @strhead\$/ || 5.16 + /^ call near ptr @strcmp\$/ || 5.17 /^ call near ptr @argstr\$/ || 5.18 /^ call near ptr @argnum\$/) { print; hold=17; next; } 5.19 s=$0