# HG changeset patch # User Pascal Bellard # Date 1606336901 0 # Node ID 431c14b76522c8e233724d8b544abbf8225f6245 # Parent fc88d0826de41c30229db1b93f9afebd4162b14f linld: fix bootiso/strhead diff -r fc88d0826de4 -r 431c14b76522 linld/stuff/src/CRTL.ASM --- a/linld/stuff/src/CRTL.ASM Tue Nov 24 08:47:45 2020 +0000 +++ b/linld/stuff/src/CRTL.ASM Wed Nov 25 20:41:41 2020 +0000 @@ -135,20 +135,17 @@ global @strcmp$qpxzct1:near proc @strcmp$qpxzct1 near - push si - xchg ax,si - dec bx -@@lp: - inc bx - lodsb - sub al,[bx] - jnz @@out - or al,[bx] - jnz @@lp -@@out: - cbw - pop si - ret +@@loop: + xchg ax,bx + mov cl,[bx] ; cl = *b++ + inc bx + xchg ax,bx + cmp cl,[bx] ; cl ?= *a++ + jnz fail ; return -1 + inc bx + or cl,cl ; clear C + jz failifc ; return 0 + jmp @@loop endp @strcmp$qpxzct1 endif @@ -169,6 +166,7 @@ open: ; open(bx) ifdef ISOHOOK +;_fastcall int open(bx:const char* name); extrn iso_open_hack:word call [iso_open_hack] ; or ret endif @@ -255,6 +253,7 @@ mov ah,3Fh endif ifdef ISOHOOK +;_fastcall int read(bx:int fd, dx:void* data, cx:int sz); extrn iso_read_hack:word call [iso_read_hack] ; or ret endif @@ -298,6 +297,7 @@ sbb cx,cx lseekset: ifdef ISOHOOK +;_fastcall long lseek(ax:int fd, cxdx:unsigned long offset, bl:whence); extrn iso_lseek_hack:word call [iso_lseek_hack] ; or ret endif @@ -417,7 +417,7 @@ endif cmp [byte bx],'|' je @@test - cmp [byte bx],0 + cmp [byte bx],dh je @@test mov al,-1 inc bx @@ -425,7 +425,7 @@ @@test: or al,al ; 1st loop ? jns @@testal - cmp [byte bx],0 + cmp [byte bx],dh jne @@loop @@testal: cmp al,'=' diff -r fc88d0826de4 -r 431c14b76522 linld/stuff/src/ISO9660.CPP --- a/linld/stuff/src/ISO9660.CPP Tue Nov 24 08:47:45 2020 +0000 +++ b/linld/stuff/src/ISO9660.CPP Wed Nov 25 20:41:41 2020 +0000 @@ -12,17 +12,17 @@ #endif #ifdef ISOHOOK -void isoroot(void) +#define isoroot() \ +{ \ + static const unsigned long root = 16UL * 2048; \ + isoreadsector(&root); \ + setdirofs(isostate.dirofs, (* (unsigned long *) (isostate.buffer + 0x9E))); \ + isostate.dirsize = filesize2dirsize(* (unsigned long *) (isostate.buffer + 0xA6)); \ +} #else int isoroot(void) -#endif { static const unsigned long root = 16UL * 2048; -#ifdef ISOHOOK - isoreadsector(&root); - setdirofs(isostate.dirofs, (* (unsigned long *) (isostate.buffer + 0x9E))); - isostate.dirsize = filesize2dirsize(* (unsigned long *) (isostate.buffer + 0xA6)); -#else if (isoreadsector(&root) == -1 || strhead(isostate.buffer+1,"CD001") == -1) { //close(isostate.fd); return -1; @@ -30,8 +30,8 @@ setdirofs(isostate.dirofs, (* (unsigned long *) (isostate.buffer + 0x9E))); isostate.dirsize = filesize2dirsize(* (unsigned long *) (isostate.buffer + 0xA6)); return 0; +} #endif -} int isoreaddir(void) { @@ -122,12 +122,7 @@ #define _64bits (x->_64bits) char *s; -#ifdef ISOHOOK - extern int _cpuhaslm(); - _64bits = _cpuhaslm(); -#else _64bits = cpuhaslm(); -#endif do { #ifdef ISOHOOK s = (char *) x->filename2open; @@ -155,7 +150,7 @@ n = "64"; i += s - name; // strlen(name); } - if (strcmp(i, n)) continue; + if (strcmp(i, n) == -1) continue; #ifndef ISOHOOK *s++ = c; #endif diff -r fc88d0826de4 -r 431c14b76522 linld/stuff/src/ISOCRTL.ASM --- a/linld/stuff/src/ISOCRTL.ASM Tue Nov 24 08:47:45 2020 +0000 +++ b/linld/stuff/src/ISOCRTL.ASM Wed Nov 25 20:41:41 2020 +0000 @@ -6,7 +6,11 @@ %crefref %noincl %nomacs + ifdef NO386 p8086 + else + p386 + endif group DGROUP _TEXT,_DATA,_BSS assume cs:DGROUP,ds:DGROUP @@ -31,7 +35,10 @@ global fold:near fold: - org 0EF00h + org 130h-100h + global _cpu_features:dword +_cpu_features dd ? + org 0F000h-100h global unfold:near unfold: jmp iso_open @@ -52,14 +59,24 @@ stosw mov al,offset iso_close_hack-0F000h stosw - global @_cpuhaslm$qv:near -@_cpuhaslm$qv: - mov ax,[130h+3] - and al,20h + ifdef NO386 + global N_LXLSH@ES:near +N_LXLSH@ES: + mov dx,es + global N_LXLSH@:near +N_LXLSH@: + mov ch,0 +@@lp: + shl ax,1 + rcl dx,1 + loop @@lp + endif ret +;*************************************************************** +;_fastcall int open(bx:const char* name); +;*************************************************************** iso_open_hack: - pop ax extrn @_isoopen$qv:near cmp [byte bx],'!' je @readmenu$qv @@ -70,33 +87,18 @@ call @_isoopen$qv cmp al,1 cmc - push bx iso_close_hack: pop bx ret - macro curseek - push cx - xor cx,cx - mov ax,4201h - cwd - call dosfd ; lseek(,0L,SEEK_CUR) - call @doseek2 - ifndef NO386 - push dx - push ax - pop eax - endif - pop cx - endm - ;*************************************************************** ;_fastcall void readmenu(void); ;*************************************************************** global @readmenu$qv:near proc @readmenu$qv near + pop ax mov dx,18 xor cx,cx call lseekset @@ -131,11 +133,11 @@ dos: int 21h failifc: - jnc @@dosok + jnc dosok fail: sbb ax,ax cwd -@@dosok: +dosok: ret endp @isolseek$qpxul @@ -168,11 +170,12 @@ mov cl,[bx] ; cl = *b++ inc bx or cl,cl ; clear C - jz failifc ; return 0 + jz fail ; return 0 xchg ax,bx xor cl,[bx] ; cl -= *a++ inc bx - and cl,0dfh ; case insensitive + or cl,cl + stc jne fail ; return -1 jmp @@loop @@ -184,97 +187,91 @@ global @strcmp$qpxzct1:near proc @strcmp$qpxzct1 near - push si - xchg ax,si - dec bx -@@lp: - inc bx - lodsb - sub al,[bx] - jnz @@out - or al,[bx] - jnz @@lp -@@out: - cbw - pop si - ret + call @strhead$qpxzct1 + jne dosok ; return -1 + xchg ax,bx + cmp cl,[bx] + jmp fail ; return 0 or -1 endp @strcmp$qpxzct1 +;*************************************************************** +;_fastcall int read(bx:int fd=isostate.fd, dx:void* data, cx:int sz); +;*************************************************************** iso_read_hack: + push dx + push cx + xor cx,cx + mov ax,4201h + cwd + ifdef SEEK_CUR + call curpos ; bx = _isostate.fileofs + else + call dosfd ; lseek(,0L,SEEK_CUR) + call sub_fileofs ; bx = _isostate.fileofs + endif ifdef NO386 + mov cx,[bx+4] ; _isostate.filesize + sub cx,ax + mov ax,[bx+6] + sbb ax,dx + pop ax + ja @@axok + je @@rem + xor ax,ax +@@rem: + cmp cx,ax + jb @@cxok +@@axok: + else push dx - curseek - mov bx,[word _isostate.filesize] - sub bx,ax - mov ax,[(word _isostate.filesize)+2] - sbb ax,dx - ja @@cxok - je @@rem + push ax + pop edx + mov eax,[bx+4] ; _isostate.filesize + sub eax,edx + pop cx + ja @@rem xor cx,cx @@rem: - cmp bx,cx + movzx ecx,cx + cmp eax,ecx ja @@cxok - mov cx,bx + endif + xchg ax,cx @@cxok: - pop dx - else - p386 - push edx - curseek - mov edx,[_isostate.filesize] - sub edx,eax - jnb @@rem - xor cx,cx -@@rem: - movzx eax,cx - cmp edx,eax - ja @@cxok - mov cx,dx -@@cxok: - pop edx - endif - or cx,cx - pop bx + pop dx ; buffer + pop bx ; skip last caller jmp readfd +;*************************************************************** +;_fastcall long lseek(ax:int fd=isostate.fd, cxdx:unsigned long offset, bl:whence); +;*************************************************************** iso_lseek_hack: xchg ax,bx - pop bx + pop bx ; skip last caller ifdef SEEK_CUR cmp al,1 ; current jne @@nocurrent +curpos: call dosfd ; lseek(,0L,SEEK_CUR) - jmp @doseek2 -@nocurrent: + jmp sub_fileofs +@@nocurrent: endif - add dx,[word _isostate.fileofs] - adc cx,[(word _isostate.fileofs)+2] + mov bx,offset _isostate.fileofs + add dx,[bx] + adc cx,[bx+2] cmp al,0 ; start je @@doseek - add dx,[word _isostate.filesize] - adc cx,[(word _isostate.filesize)+2] + add dx,[bx+4] ; _isostate.filesize + adc cx,[bx+6] @@doseek: call lseekset ; lseek(,0L,SEEK_SET) -@doseek2: - sub ax,[word _isostate.fileofs] - sbb dx,[(word _isostate.fileofs)+2] +sub_fileofs: + mov bx,offset _isostate.fileofs + sub ax,[bx] + sbb dx,[bx+2] ret - ifdef NO386 - global N_LXLSH@ES:near -N_LXLSH@ES: - mov dx,es - global N_LXLSH@:near -N_LXLSH@: - mov ch,0 -@@lp: - shl ax,1 - rcl dx,1 - loop @@lp - ret - endif - ends _TEXT end diff -r fc88d0826de4 -r 431c14b76522 linld/stuff/src/JUMP.ASM --- a/linld/stuff/src/JUMP.ASM Tue Nov 24 08:47:45 2020 +0000 +++ b/linld/stuff/src/JUMP.ASM Wed Nov 25 20:41:41 2020 +0000 @@ -134,8 +134,11 @@ push dx ; size hi endif push si ; size lo=up to 512k - extrn _imgs:dword - push [dword _imgs+2] ; src ofs = pm.fallback + + include "himem.inc" + + extrn _imgs:image_himem + push [_imgs.fallback] ; src ofs = pm.fallback ;in al,70h ;or al,80h ; disable NMI diff -r fc88d0826de4 -r 431c14b76522 linld/stuff/src/pipehole.awk --- a/linld/stuff/src/pipehole.awk Tue Nov 24 08:47:45 2020 +0000 +++ b/linld/stuff/src/pipehole.awk Wed Nov 25 20:41:41 2020 +0000 @@ -315,7 +315,7 @@ if (/al,/ || /,al/) sub(/al/,"cl") if (/cmp byte ptr \[si\+34\],0/) $0=" or cl,cl" if (/jne @@0$/) next - if (/jmp @3@58$/) $0=" je @3@58" + if (/jmp @.@58$/) sub(/jmp/,"je") sub(/mov ax,-1/,"dec ax") } } # file == "iso9660.cpp" @@ -750,6 +750,7 @@ /^ call near ptr @isoopen\$/ || /^ call near ptr @isoreadsector\$/ || /^ call near ptr @strhead\$/ || + /^ call near ptr @strcmp\$/ || /^ call near ptr @argstr\$/ || /^ call near ptr @argnum\$/) { print; hold=17; next; } s=$0