# HG changeset patch # User Pascal Bellard # Date 1615751720 0 # Node ID 217c02cbbe8d9d719c4130ace10ce68404d8bda0 # Parent 010fc15e8b9d558192ff4e2ec2d2d329a6f1e246 linld: basic iso9660 support diff -r 010fc15e8b9d -r 217c02cbbe8d busybox/stuff/busybox-1.31.config-static --- a/busybox/stuff/busybox-1.31.config-static Sat Mar 06 18:53:34 2021 +0000 +++ b/busybox/stuff/busybox-1.31.config-static Sun Mar 14 19:55:20 2021 +0000 @@ -279,7 +279,7 @@ # CONFIG_OD is not set # CONFIG_PASTE is not set # CONFIG_PRINTENV is not set -# CONFIG_PRINTF is not set +CONFIG_PRINTF=y CONFIG_PWD=y # CONFIG_READLINK is not set # CONFIG_FEATURE_READLINK_FOLLOW is not set @@ -441,7 +441,7 @@ # CONFIG_FEATURE_FIND_MTIME is not set # CONFIG_FEATURE_FIND_MMIN is not set # CONFIG_FEATURE_FIND_PERM is not set -# CONFIG_FEATURE_FIND_TYPE is not set +CONFIG_FEATURE_FIND_TYPE=y # CONFIG_FEATURE_FIND_EXECUTABLE is not set # CONFIG_FEATURE_FIND_XDEV is not set # CONFIG_FEATURE_FIND_MAXDEPTH is not set @@ -1111,7 +1111,7 @@ # CONFIG_ASH_IDLE_TIMEOUT is not set # CONFIG_ASH_MAIL is not set # CONFIG_ASH_ECHO is not set -# CONFIG_ASH_PRINTF is not set +CONFIG_ASH_PRINTF=y # CONFIG_ASH_TEST is not set # CONFIG_ASH_HELP is not set # CONFIG_ASH_GETOPTS is not set diff -r 010fc15e8b9d -r 217c02cbbe8d linld/stuff/src/COMMON.H --- a/linld/stuff/src/COMMON.H Sat Mar 06 18:53:34 2021 +0000 +++ b/linld/stuff/src/COMMON.H Sun Mar 14 19:55:20 2021 +0000 @@ -1,7 +1,8 @@ //#define WITH_XMM_ALLOC add himem.sys driver //#define LARGE_ZIMAGE may load system in high memory temporarily //#define INT15_E820 add int15/eax=E820 driver -//#define BASIC_ISO9660 non rockridge support +//#define RAW_ISO9660 raw filename support with ';1' or '.' trailers +#define BASIC_ISO9660 non rockridge support #define ROCKRIDGE iso 9660 posix name support #define ISO9660 iso= support #define QUICK_BOOT /q bypass shutdown hack, /v keeps v86 @@ -18,9 +19,6 @@ /* End of the optional features */ #ifdef ISOHOOK -#ifndef ISO9660 -#define ISO9660 -#endif #ifndef ROCKRIDGE #define ROCKRIDGE #endif @@ -28,6 +26,11 @@ #define CPU64 #endif #endif +#if defined(ROCKRIDGE) || defined(BASIC_ISO9660) || defined(RAW_ISO9660) +#ifndef ISO9660 +#define ISO9660 +#endif +#endif // This file is distributed under GPL // @@ -92,6 +95,8 @@ extern u8 pm_low; +extern u8 buf4k[4096]; + extern u32 far *initrd_desc; #define cmdline (cmdstr[0]) #define kernel_name (cmdstr[1]) diff -r 010fc15e8b9d -r 217c02cbbe8d linld/stuff/src/CRTL.ASM --- a/linld/stuff/src/CRTL.ASM Sat Mar 06 18:53:34 2021 +0000 +++ b/linld/stuff/src/CRTL.ASM Sun Mar 14 19:55:20 2021 +0000 @@ -34,17 +34,14 @@ segment _BSS byte public use16 'BSS' - ifdef ISO9660 - include "isostate.inc" - public _isostate -_isostate isostate - org $-7 - endif - global buf4k:byte -label buf4k byte -_xfer_buf db 4096 dup (?) -filecnt db ? ; in fact 0 minus file count... -nextfilename dw ? + ifdef ISO9660 + global _buf2k:byte +label _buf2k byte + db 2048 dup (?) + endif + global _buf4k:byte +label _buf4k byte + db 4096 dup (?) ends _BSS @@ -110,7 +107,7 @@ mov ax,3d00h ; read-only+compatibility else mov ah,3dh ; read-only+compatibility - mov dx,bx + mov dx,bx ; open(DS:DX=filename,al=access,cl=attributes) endif ;mov cl,0 ; attribute mask call dos @@ -135,6 +132,10 @@ ret ifdef ISO9660 + + include "isostate.inc" + extrn _isostate:isostate + ;*************************************************************** ;_fastcall int:C open(bx:const char* name, int flags=O_RDONLY); ;_fastcall int:C openargs(bx:const char* name, int flags=O_RDONLY); @@ -182,7 +183,7 @@ global close:near ; close(ax) close: - mov bh,3Eh + mov bh,3Eh ; close(BX:handle) ifdef ISO9660 mov cx,[_isostate.fd] jcxz dosbx @@ -232,7 +233,7 @@ pop bx endif readfd: - mov ah,3Fh + mov ah,3Fh ; read(BX=handle,DS:DX=to,CX=count) ;jcxz fail dos: int 21h @@ -274,14 +275,14 @@ ;*************************************************************** proc @readmenu$qv near - mov dx,18 + mov dx,20 xor cx,cx call seeksetpos0 ; filepos = 0 - mov dx,offset _isostate.filemod - ; //magic = x->filemod; - mov cl,10 - call readfd ; // read x->filemod + x->fileofs & x->filesize - mov bx,offset _isostate.fileofs + mov dx,offset _isostate.fileofs + mov cl,8 + push dx + call readfd ; // read x->fileofs & x->filesize + pop bx ; x->fileofs = 0x7FF0 - (x->filesize &= 0xFFFF); mov ax,7FF0h cwd @@ -335,9 +336,9 @@ call isolseek ; filepos = 0 jc fail - mov dh,10 - mov ax,offset _isostate.buffer - jmp @read$dxaxbx ; read(fd,buffer,2560+) + mov cx,2048 + mov dx,offset _buf2k + jmp readfd ; read(fd,buf2k,2048) endp @isoreadsector$qpxul endif @@ -394,9 +395,11 @@ inc bx xchg ax,bx xor dl,[bx] ; dl ^= *a++ + ifndef RAW_ISO9660 ifndef ROCKRIDGE and dl,0dfh ; case insensitive endif + endif jne fail ; return -1 inc bx or dl,dl ; clear C @@ -947,7 +950,7 @@ else les ax,[dword di] endif - mov cx,offset _xfer_buf + mov cx,offset _buf4k storepage: ; storepage(edx,cx) ifndef NO386 push 0 @@ -1066,7 +1069,7 @@ xchg ax,cx @@szok: jcxz image_done - lea dx,[di+_xfer_buf] + lea dx,[di+_buf4k] mov bx,[(image_himem si).fd] call @read$cxdxbx jb image_done @@ -1083,7 +1086,7 @@ @@fill: test al,3 je @@filled - mov [di+_xfer_buf],dl + mov [di+_buf4k],dl inc di inc ax jmp @@fill diff -r 010fc15e8b9d -r 217c02cbbe8d linld/stuff/src/ISO9660.CPP --- a/linld/stuff/src/ISO9660.CPP Sat Mar 06 18:53:34 2021 +0000 +++ b/linld/stuff/src/ISO9660.CPP Sun Mar 14 19:55:20 2021 +0000 @@ -11,10 +11,13 @@ { \ extern void isoreadrootsector(void); \ isoreadrootsector(); \ - setdirpage(x->dirpage, (* (unsigned long *) (isostate.buffer + 0x9E))); \ - x->dirsize = filesize2dirsize(* (unsigned long *) (isostate.buffer + 0xA6)); \ + setdirpage(x->dirpage, (* (unsigned long *) (buf2k + 0x9E))); \ + x->dirsize = filesize2dirsize(* (unsigned long *) (buf2k + 0xA6)); \ } +#ifdef RAW_ISO9660 +#define BASIC_ISO9660 +#endif #if !defined(BASIC_ISO9660) && !defined(ROCKRIDGE) #define BASIC_ISO9660 #endif @@ -24,25 +27,27 @@ struct isostate *x=&isostate; - p = x->buffer; + p = buf2k; if (x->curpos >= SECTORSZ || * (short *) (p + x->curpos) == 0) { + x->curpos = 0; if ((x->curdirsize =- DIRSECTORSZ) < 0) return -1; isoreadsector(&x->curdirofs); // x->filepos = 0 //x->curdirofs += SECTORSZ; *(int *)((char *) &x->curdirofs+1) += SECTORSZ/256; - x->curpos = 0; } p += x->curpos; x->fileofs = (* (unsigned long *) (p + 2)) << SECTORBITS; if ((x->entrysize = * (short *) p) == 0) { return -1; } - x->filemod = 0x81ED; if (p[25] & 2) ((char *)&(x->filemod))[1] = 0x41; +#ifdef CHECKISOFILETYPE + x->c = p[25]; +#endif register char *s; x->filesize = * (unsigned long *) (p + 10); s = ".."+1-p[33]; #ifdef ROCKRIDGE - p = x->buffer + 34 + ((p[32] + x->curpos) & -2); + p = buf2k + 34 + ((p[32] + x->curpos) & -2); x->curpos += x->entrysize; do { register len = p[2]; @@ -52,19 +57,21 @@ goto found; } p += len; - } while (x->buffer + x->curpos - 3 >= p); + } while (buf2k - 3 + x->curpos >= p); #endif #ifdef BASIC_ISO9660 # ifdef ROCKRIDGE - p = x->buffer + 32 + x->curpos - x->entrysize; + p = buf2k + 32 + x->curpos - x->entrysize; # else x->curpos += x->entrysize; p += 32; # endif if (((* (short *) p) & 0xFEFF) -1 != 0) { s = p + 1; p += *p; - if (* (short *) (p-1) != 0x313B) p+=2; // no ;1 to remove +# ifndef RAW_ISO9660 + if (* (short *) (p-1) == 0x313B) p-=2; // remove ;1 if (*p != '.') p++; +# endif *p = 0; } #endif @@ -92,12 +99,12 @@ s = (char *) x->filename2open; if (*s == '/') { + isoroot(); + //if (strncmp(buf2k+1,"CD001",5) == -1) return -1; + //if (*(int*)(buf2k+1) != 0x4443) return -1; + next: s++; - isoroot(); - //if (strncmp(x->buffer+1,"CD001,5) == -1) return -1; - //if (*(int*)(x->buffer+1) != 0x4443) return -1; } - next: name = s; do s++; while (*s && *s != '/'); c = *s; *s = 0; @@ -125,12 +132,14 @@ #endif if (strcmp(i, n) != -1) break; } while (1); - *s++ = c; -#define IS_DIR(x)( (*((char*) &x + 1) & (char)0676) == (char)0) - if (IS_DIR(x->filemod)) { + *s = c; + if (c) { +#ifdef CHECKISOFILETYPE + if ((x->c & 2) == 0) return -1; +#endif cpytodirpage(x->dirpage, x->fileofs); x->dirsize = filesize2dirsize(x->filesize); - if (c) goto next; + goto next; } isolseek(&x->fileofs); return x->fd; diff -r 010fc15e8b9d -r 217c02cbbe8d linld/stuff/src/ISO9660.H --- a/linld/stuff/src/ISO9660.H Sat Mar 06 18:53:34 2021 +0000 +++ b/linld/stuff/src/ISO9660.H Sun Mar 14 19:55:20 2021 +0000 @@ -10,7 +10,6 @@ unsigned curpos; char *filename2open; int fd; - unsigned short filemod; unsigned long fileofs; unsigned long filesize; unsigned long filepos; @@ -19,18 +18,16 @@ typedef unsigned dirpagetype; dirpagetype dirpage; unsigned long curdirofs; + char _64bits; + char c; int entrysize; const char *tmp; - char c; - char _64bits; #define SECTORSZ 2048 #define SECTORBITS 11 - char buffer[SECTORSZ+512]; // RR overflow } isostate; #define isofd isostate.fd #define isofileofs isostate.fileofs #define isofilesize isostate.filesize -#define isofilemod isostate.filemod #define isofilename isostate.filename extern _fastcall void isolseek(const unsigned long *offset); extern _fastcall int isoreadsector(const unsigned long *offset); @@ -38,4 +35,5 @@ extern int isoreaddir(void); #define isolabel() do { isofileofs=0x8028; isofilesize=32; } while (0) #define setiso(x) (isostate.fd = open(x)) +extern u8 buf2k[2048]; #endif diff -r 010fc15e8b9d -r 217c02cbbe8d linld/stuff/src/ISOSTATE.INC --- a/linld/stuff/src/ISOSTATE.INC Sat Mar 06 18:53:34 2021 +0000 +++ b/linld/stuff/src/ISOSTATE.INC Sun Mar 14 19:55:20 2021 +0000 @@ -4,19 +4,19 @@ curpos dw ? ; 0 unsigned curpos; filename2open dw ? ; 2 char *filename2open; fd dw ? ; 4 int fd; -filemod dw ? ; 6 unsigned short filemod; -fileofs dd ? ; 8 unsigned long fileofs; -filesize dd ? ;12 unsigned long filesize; -filepos dd ? ;16 unsigned long filepos; -filename dw ? ;20 char *filename; -curdirsize dw ? ;22 dirsizetype curdirsize; -dirsize dw ? ;24 dirsizetype dirsize; -dirpape dw ? ;26 unsigned short dirpage; -curdirofs dd ? ;28 unsigned long curdirofs; +fileofs dd ? ; 6 unsigned long fileofs; +filesize dd ? ;10 unsigned long filesize; +filepos dd ? ;14 unsigned long filepos; +filename dw ? ;18 char *filename; +curdirsize dw ? ;20 dirsizetype curdirsize; +dirsize dw ? ;22 dirsizetype dirsize; +dirpape dw ? ;24 unsigned short dirpage; +curdirofs dd ? ;26 unsigned long curdirofs; +_64bits db ? ;30 char _64bits; ;overlap +c db ? ;31 char c; entrysize dw ? ;32 int entrysize; tmp dw ? ;34 const char *tmp; -c db ? ;36 char c; -_64bits db ? ;37 char _64bits; -buffer db ? ;38 char buffer[2048+512]; ends isostate ; } isostate; + +ISOSTATE_OVERLAP = 5 diff -r 010fc15e8b9d -r 217c02cbbe8d linld/stuff/src/JUMP.ASM --- a/linld/stuff/src/JUMP.ASM Sat Mar 06 18:53:34 2021 +0000 +++ b/linld/stuff/src/JUMP.ASM Sun Mar 14 19:55:20 2021 +0000 @@ -289,8 +289,6 @@ endp _boot_kernel -movedend: - ends _TEXT end diff -r 010fc15e8b9d -r 217c02cbbe8d linld/stuff/src/LINK.CMD --- a/linld/stuff/src/LINK.CMD Sat Mar 06 18:53:34 2021 +0000 +++ b/linld/stuff/src/LINK.CMD Sun Mar 14 19:55:20 2021 +0000 @@ -1,1 +1,1 @@ -_beg.obj linld.obj memtop.obj memcpy32.obj jump.obj vcpi.obj xmm.obj a20.obj crtl.obj load.obj himem.obj iso9660.obj _end.obj, linld +_beg.obj linld.obj jump.obj memtop.obj memcpy32.obj vcpi.obj xmm.obj a20.obj crtl.obj load.obj himem.obj iso9660.obj _end.obj, linld diff -r 010fc15e8b9d -r 217c02cbbe8d linld/stuff/src/LINLD.CPP --- a/linld/stuff/src/LINLD.CPP Sat Mar 06 18:53:34 2021 +0000 +++ b/linld/stuff/src/LINLD.CPP Sun Mar 14 19:55:20 2021 +0000 @@ -9,9 +9,9 @@ extern char bzimagestr[]; const char* cmdstr[4] = {"auto",bzimagestr,NULL,NULL}; #ifdef QUICK_BOOT -u32 cmdnum[7]; +extern u32 cmdnum[7]; #else -u32 cmdnum[5]; +extern u32 cmdnum[5]; #endif inline void syntax() { @@ -44,7 +44,6 @@ ); } -extern char buf_cmdline[128]; int main(int argc, char *argv[]) { (void) argc; @@ -76,17 +75,25 @@ kernel_name=*argv; continue; } - *clp = (const char *) buf_cmdline + 1; - strcatb((const char *) buf_cmdline,*argv); + *clp = (const char *) heap_top +1; + strcatb((const char *) heap_top,*argv); } while (*++argv); puts(*clp); + asm{ + xchg ax,bx + mov bx,offset _heap_top + cmp ax,[bx] + jc skip + mov [bx],ax + } +skip: #ifdef ISO9660 if (isofile) setiso(isofile); #endif set_cmdline(*clp); load_kernel(); load_initrd(); - boot_kernel(); + //boot_kernel(); // Let compiler be happy return _AX; diff -r 010fc15e8b9d -r 217c02cbbe8d linld/stuff/src/LOAD.CPP --- a/linld/stuff/src/LOAD.CPP Sat Mar 06 18:53:34 2021 +0000 +++ b/linld/stuff/src/LOAD.CPP Sun Mar 14 19:55:20 2021 +0000 @@ -116,9 +116,6 @@ #else #define topseg() 0x9000 #endif -static u16 rm_size; -static u8* rm_buf; // @ = @rm_size + 2, see A20.ASM -struct image_himem imgs[2]; void load_kernel() { diff -r 010fc15e8b9d -r 217c02cbbe8d linld/stuff/src/MEMCPY32.ASM --- a/linld/stuff/src/MEMCPY32.ASM Sat Mar 06 18:53:34 2021 +0000 +++ b/linld/stuff/src/MEMCPY32.ASM Sun Mar 14 19:55:20 2021 +0000 @@ -231,6 +231,9 @@ endp memcpy32 + global movedend:near +movedend: + ends _TEXT end diff -r 010fc15e8b9d -r 217c02cbbe8d linld/stuff/src/VCPI.ASM --- a/linld/stuff/src/VCPI.ASM Sat Mar 06 18:53:34 2021 +0000 +++ b/linld/stuff/src/VCPI.ASM Sun Mar 14 19:55:20 2021 +0000 @@ -160,8 +160,8 @@ sub edi,edx mov al,3 ;add present+writable bits mov [bx+di],eax ;stuff it into pagedir[0] - push ds - pop es ;es:di->page0,es:di+1000h->pagedir + ;push ds + ;pop es ;es:di->page0,es:di+1000h->pagedir ;page directory will use only one entry (4 bytes): ;cr3 => pagedir => page0 => ######## ; (1 entry) (1024 => # 4M # diff -r 010fc15e8b9d -r 217c02cbbe8d linld/stuff/src/_BEG.ASM --- a/linld/stuff/src/_BEG.ASM Sat Mar 06 18:53:34 2021 +0000 +++ b/linld/stuff/src/_BEG.ASM Sun Mar 14 19:55:20 2021 +0000 @@ -8,6 +8,38 @@ %nomacs include "common.inc" + include "himem.inc" + include "isostate.inc" + + ifdef QUICK_BOOT +CMDNUMCNT = 7 + else +CMDNUMCNT = 5 + endif + + macro alloc_isostate + public _isostate +_isostate isostate + org $-ISOSTATE_OVERLAP + endm + + macro alloc_image +rm_size dw ? ; _imgs-4 +rm_buf dw ? ; _imgs-2 + global _imgs:byte +label _imgs byte +img_kernel image_himem ? +img_initrd image_himem ? + endm + + macro alloc_misc + global _cmdnum:word +label _cmdnum word + dd CMDNUMCNT dup(?) + + global _himem_buf:dword +_himem_buf dd ? + endm p8086 @@ -34,6 +66,14 @@ segment _BSS byte public use16 'BSS' + ifdef ISO9660 + ifndef VCPI + alloc_isotate + else +room_for_isostate = 1 + endif + endif + ifdef ISOHOOK extrn _big_cmdline:byte db 254 dup(?) @@ -45,11 +85,27 @@ _cpu386 db ? ifdef CPU64 org $-1 - endif - ifdef CPU64 global _cpu_features:dword _cpu_features dd ? +room_for_image = 1 + else + alloc_image endif + + ifndef BSS_OVERLAP_BOOT + + ifdef room_for_isostate + alloc_isostate + endif + + ifdef room_for_image + alloc_image + endif + + alloc_misc + + endif + ends _BSS segment _TEXT byte public use16 'CODE' @@ -67,11 +123,6 @@ ;*************************************************************** mov sp,offset stktop mov bx, 0F000h ; cld ; cli & empty string - org $-4-2 - global _himem_buf:dword -_himem_buf dd ? - global _buf_cmdline:word -_buf_cmdline dw ? ; 128 bytes, must start with 00 mov si,offset _bss_start clearbss: mov [si],bl ; clear bss + heap @@ -128,8 +179,10 @@ ifdef VCPI ; Check whether it is safe to call 67h xor eax,eax - mov es,ax - cmp [dword es:67h*4],eax + push ds + mov ds,ax + cmp [dword 67h*4],eax + pop ds je no_vcpi mov ah,0DEh ; check for vcpi present int 67h @@ -187,11 +240,6 @@ ;*************************************************************** ; build argv & argc ;*************************************************************** - extrn _bss_end:word - mov di,offset _bss_end - global _heap_top - org $-2 -_heap_top dw ? mov si,80h ifdef ISOHOOK mov bx,offset _big_cmdline @@ -212,6 +260,41 @@ endif xchg ax,bx mov [bx+si],bh ; set eos + +;*************************************************************** + + ifdef BSS_OVERLAP_BOOT + mov al,0 + mov di,100h + mov cx,offset clean-100h + + org $-(CMDNUMCNT*4)-4 + + ifdef room_for_image + org $-2-2-(2*size image_himem) + endif + + ifdef room_for_isostate + org $+ISOSTATE_OVERLAP-size isostate + alloc_isostate + endif + + ifdef room_for_image + alloc_image + endif + + alloc_misc +clean: + rep + stosb + endif + +;*************************************************************** + extrn _bss_end:word + mov di,offset _bss_end + global _heap_top + org $-2 +_heap_top dw ? ;xor dx,dx ;push dx ; envp (already cleared) ;mov [word di],dx ; argv[0] = 0 (idem) diff -r 010fc15e8b9d -r 217c02cbbe8d linld/stuff/src/pipehole.awk --- a/linld/stuff/src/pipehole.awk Sat Mar 06 18:53:34 2021 +0000 +++ b/linld/stuff/src/pipehole.awk Sun Mar 14 19:55:20 2021 +0000 @@ -9,6 +9,7 @@ if (file == "" && /debug S/) { file=$3; gsub(/\"/,"",file) } if (/debug S/) print " %PAGESIZE 1000" if (file == "linld.cpp") { +#print " linld=" islinld " ;" $0 if (/\[si/ || /si,/ || /,si/) sub(/si/,"di") else if (/\[di/ || /di,/ || /,di/) sub(/di/,"si") if (/add di,2/) $0=" scasw ; " $0 @@ -24,6 +25,7 @@ if (islinld==3 && /bx,word ptr/) { print "; " $0; next } if (/fileexist\$qpxzc/) islinld=4 if (islinld==4) { + if (/DGROUP:_heap_top/) next if (/ax,-1/) { print " inc ax" print " mov ax,word ptr [di]" @@ -46,6 +48,14 @@ print " mov bx,word ptr [si+6]" $0=" or bx,bx" } + if (/heap_top \+1;/) islinld=6 + if (islinld==6) { + sub(/ax/,"bx") + if (/strcatb/) { + print " dec bx" + islinld=4 + } + } } # file == "linld.cpp" if (file == "himem.cpp") { if (/sp,bp/ || /pop bp/ || /enter/ || /leave/) next @@ -243,52 +253,54 @@ } } # file == "load.cpp" if (file == "iso9660.cpp") { - if (/ptr \[si\+8\],/) { si="si"; di="di" } - if (/ptr \[di\+8\],/) { si="di"; di="si" } - if (/leave/ || /enter/ || /bp-2/ || /bp,sp/ || /push bp/ || /sub sp,/) next - if (/ptr \[.i\+10\],dx/) next - if (/ptr \[.i\+8\],ax/) next - if (/ptr \[.i\+8\],eax/) next + if (/di,offset DGROUP:_buf2k/) { si="si"; di="di" } + if (/si,offset DGROUP:_buf2k/) { si="di"; di="si" } + if (/leave/ || /enter/ || /bp/ || /sub sp,/) next + if (/ptr \[.i\+8\],dx/) next + if (/ptr \[.i\+6\],ax/) next + if (/ptr \[.i\+6\],eax/) next if (/x,word ptr \[.i\+32\]/) next +#print " iso=" isiso " ;" $0 if (/add word ptr \[.i\],ax/) sub(/ax/,"cx") - if (/ax,word ptr \[si\+24\]/) sub(/mov ax,/,"les ax,d") - if (/ax,word ptr \[si\+26\]/) next - if (/word ptr \[si\+29\],ax/) sub(/ax/,"es") - if (/\[si\],-1/) $0=" not word ptr [si]" + if (/ax,word ptr \[si\+22\]/) sub(/mov ax,/,"les ax,d") + if (/ax,word ptr \[si\+24\]/) next + if (/word ptr \[si\+27\],ax/) sub(/ax/,"es") sub(/di,word ptr DGROUP:_isostate\+2/,"di,word ptr [si+2]") - if (/p = x->buffer \+ 32 \+ x->curpos/) isiso=21 -#print "iso=" isiso " ; " $0 + if (/p = buf2k \+ 32 \+ x->curpos/) isiso=21 + sub(/-257/,"-257 ; clear C") if (isiso == 21) { # ISO9660.LST - if (/si,ax/) next - if (/ax,70/) { - print " lea si,[bx+3+32]" - $0=" sub si,cx" - } + if (/si,ax/) $0=" sub si,cx" + sub(/ax,/,"si,") if (/# else/) isiso=0 } - if (/cx,si/) isiso=20 + if (/cx,si/) { + if (isiso == 0) print " inc " di + isiso=20 + } if (isiso == 20) { # ISO9660.LST if (/bx,dx/) { isiso=12 next } + if (/inc cx/) next if (/al,byte ptr/) $0=" ;inc ax" - sub(/\[si-1\]/,"[si]") - if (/p != .\./) print " inc " di " ; see ;inc ax" - if (/i],0/) sub(/,0/,",ah") + if (/i],0/) { + sub(/,0/,",ah ; clear C") + sub(/mov/,"and") + } sub(/cx/,"dx") if (/filename = s;/) { isiso=0 } } if (isiso == 19) { # ISO9660.LST - if (/short @2@282/) $0=" jc restoreC" - if (/si\+34/ || /ax,dx/ || /ax,di/ || /cmp ax,-1/ || /sub ax,/) next + if (/short @2@310/) $0=" jc restoreC" + if (/si\+32/ || /ax,dx/ || /ax,di/ || /cmp ax,-1/ || /sub ax,/) next sub(/dx,/,"ax,") - if (/ax,word ptr \[si\+20\]/) sub(/ax/,"bx") + if (/ax,word ptr \[si\+18\]/) sub(/ax/,"bx") if (/bx,offset/) sub(/bx/,"ax") if (/short @2@282/) sub(/je/,"jnc") - if (/\[si\+37\],0/) sub(/,0/,",ch") + if (/\[si\+35\],0/) sub(/,0/,",ch") if (/@strcmp\$qpxzct1/) { print print "restoreC:" @@ -296,71 +308,75 @@ isiso=1 } } - if (/ax,-8/) { isiso=18; next } if (isiso == 18) { # ISO9660.LST - if (/ax,ax/) { isiso=0;next } - sub(/mov/,"sub") - sub(/,ax/,",8") + if (/endif/) isiso=1 } if (isiso == 17) { # ISO9660.LST - if (/inc di/) $0="; " $0 - if (/_isostate\+205/) { + if (/si\+22/) { + print "next:" + print " mov word ptr [si+24],bx" print - $0=" jmp setdirofsnsz" + isiso=0 + } + if (/_buf2k\+167/) { + print + $0="" } else sub(/ax/,"bx") - if (/si\+24/) isiso=0 if (/,bx/) next if (/isoreadrootsector/) { print - print " xor word ptr [si+39],17475 ; clear C" - $0=" jne returnNotC" + print " mov ax,word ptr [_buf2k+1]" + print " xor ax,17475 ; clear C, CD" + print "jne_returnNotC:" + print " cmc" + $0=" jne returnC" } } - if (/cpytodirpage.x->dirpage/) isiso=16 + if (/if \(c\)/) isiso=16 if (isiso == 16) { # ISO9660.LST - if (/filesize2dirsize/) { - print " mov bx,word ptr [si+9]" - print " mov ax,word ptr [si+13]" - print "setdirofsnsz:" - print " inc di" - print " mov word ptr [si+26],bx" + if (/cmp/) { + print " mov bx,word ptr [si+7]" + print " mov ax,word ptr [si+11]" + print " dec cx" + print " jns next" } - if (/ax,/ || /si\+13/ || /si\+26/) next - if (/si\+24/) isiso=1 + if (/isolseek/) isiso=1 + else if (! /;/) next } if (/found:/) isiso=15 if (isiso != 15 && /si,offset DGROUP:_isostate/) $0=";" $0 if (isiso == 15) { # ISO9660.LST if (/xor/) { - print " stc" - print "returnNotC:" - print " cmc" print "returnC:" print " sbb ax,ax" print "return:" next } - if (/i\+20\],cx/) sub(/cx/,"dx") - if (/@1@422:/ || /bp$/ || /bp,sp/ || /sp,2/) next + if (/i\+18\],cx/) sub(/cx/,"dx") + if (/@1@422:/) next if (/\[di\],47/) isiso=17 } - if (/short @1@142/) { isiso=14; next } if (isiso == 14) { # ISO9660.LST - if (/ax,-1/) next + if (/ax,/ || /jge/) next + sub(/mov/,"sub") + sub(/,ax/,",8") if (/jmp/) { - print " JUMPS" - print " jb returnC" - $0=" NOJUMPS" + print " ;JUMPS" + print " jb returnCXZC" + $0=" ;NOJUMPS" + isiso=0 } } - if (/p = x->buffer \+ 34/) isiso=13 + if (/p = buf2k \+ 34/) isiso=13 if (isiso == 13) { # ISO9660.LST if (/cbw/) $0=" ;cbw" if (/i,.i/) $0=" xchg ax,bx" - if (/i,ax/) $0=" lea " di ",[bx+" si "+72]" - if (/i,72/ || /word ptr \[.i\+32\]/) next - if (/register len/) isiso=12 + if (/i,ax/) $0=" xchg ax," di + if (/i,70/ || /word ptr \[.i\+32\]/) next + if (/register len/) { + isiso=12 + } } if (isiso == 12) { # ISO9660.LST if (/.i\+2/) sub(/al/,"bl") @@ -373,25 +389,28 @@ if (/while/) isiso=120 } if (isiso == 120) { # ISO9660.LST - sub(/ax,/,"bx,") + sub(/ax/,"bx") + if (/cmp bx,/) $0=" cmp " di ",bx" + sub(/jae/,"jb") if (/endif/) isiso=0 } if (/curpos >= SECT/) isiso=10 if (isiso == 10) { # ISO9660.LST - if (/cmp/) { + if (/,2048/) { + print " xor cx,cx" sub(/cmp /,"mov bx,") sub(/i.*/,"i]") print $0=" cmp bh,2048/256" } - if (/mov/) { - isiso=0 - next - } + if (/DGROUP:_buf2k\[bx\],0/) $0=" cmp word ptr [bx+" di "],cx" + sub(/,0/,",cx") + if (/\[.i\],cx/) isiso=14 + else if (/mov/) next } if (/<< SECTORBITS/) isiso=9 if (isiso == 9) { # ISO9660.LST - if (/dx,/) next + if (/dx,/) next sub(/mov ax,/,"les ax,d") if (/^ call/) { print " extrn N_LXLSH@ES:near" @@ -405,53 +424,60 @@ sub(/mov dx,/,"les dx,d") sub(/\],ax/,"],es") sub(/cx,/,"dx,") - if (/filemod/) isiso=0 + if (/sub/) isiso=0 } if (/entrysize =/) isiso=5 if (isiso == 5) { # ISO9660.LST if (/ax,ax/) next - if (/word ptr \[.i\+32\],ax/) next + if (/word ptr \[.i\+3.\],ax/) next sub(/ax/,"cx") sub(/je/,"jcxz") if (/jcxz/) { hold=0 print s - sub(/@1@114/,"returnNotC") + print " stc" + print "returnCXZC:" + sub(/@1@1../,"returnC") print - if (is386) $0=" mov dword ptr [" si "+8],eax" + if (is386) $0=" mov dword ptr [" si "+6],eax" else { - print " mov word ptr [" si "+10],dx" - $0=" mov word ptr [" si "+8],ax" + print " mov word ptr [" si "+8],dx" + $0=" mov word ptr [" si "+6],ax" } } if (/return/) isiso=0 } if (/do s\+\+; while/) isiso=3 if (isiso == 3) { # ISO9660.LST + if (/do \{/) print "while1:" sub(/cmp byte ptr \[.i\]/,"sub al") if (/inc /) { r=$2; print; next } if (/al,0/) print " mov al,[" r "]" if (/al,byte ptr \[/) next if (/byte ptr \[.*\],0/) next + if (/byte ptr \[si\+31\],al/) next } if (/ptr .isoreaddir/) isiso=1 if (isiso == 1) { # ISO9660.LST + if (/xor/) isiso=18 if (/n = name;/) { isiso=19 print " xchg ax,cx" print " xchg cl,byte ptr [di] ; c" } - if (/short @2@366/) sub(/jne/,"jnc") - if (/short @2@282/) sub(/je/,"jc") - if (/short @2@562/) sub(/@2@562/,"returnNotC") + sub(/jne/,"jnc") + if (/short @2@450/) $0=" jc returnC" + if (/je/) $0=" jc while1" + if (/short @2@562/) sub(/@2@562/,"jne_returnNotC") + if (/jmp/) $0=" jmp jne_returnNotC" if (/ax,word ptr \[si\+4\]/) $0=" xchg ax,bx ; " $0 - if (/\[di\],al/) next - if (/@2@310/) next + if (/\[di\],al/ || /al,byte ptr/) next + if (/@2@338/) next if (/ax,-1/) next if (/inc di/ || /@@0/) next - if (/@2@142$/) { print " inc di"; sub(/jmp/,"loop") } + if (/@2@142$/) print " inc di" } - if (/i\+36\]/) next + if (/i\+34\]/) next sub(/di,offset DGROUP:_isostate/,"di,si") } # file == "iso9660.cpp" if (wascall) { @@ -785,7 +811,7 @@ } if (afterjmp) print ";" $0 else print - if (/^ jmp / || /^ call near ptr _boot_kernel/ || + if (/^ jmp / || /boot_kernel\(\);/ || /^ call near ptr @die\$qpxzc/ || /^ call near ptr @exit\$qv/) afterjmp=1 }