From b0b403d4981c1f89be2a70f332b27e5adbac6a2b Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 22 May 1998 00:39:22 +0000 Subject: [PATCH] * go32v1, go32v2 recompiles with the new objects * remake3 works again with go32v2 - removed some "optimizes" from daniel which were wrong --- rtl/dos/dos.pp | 739 +++++++++--------- rtl/dos/go32v1/makefile | 20 +- rtl/dos/go32v1/os.inc | 28 +- rtl/dos/go32v1/prt0.as | 87 +-- rtl/dos/go32v1/system.pp | 602 +++++++-------- rtl/dos/go32v2/makefile | 15 +- rtl/dos/go32v2/v2prt0.as | 1522 +++++++++++++++++++------------------- rtl/dos/graph.pp | 47 +- rtl/dos/mouse.pp | 32 +- rtl/dos/printer.pp | 73 +- 10 files changed, 1485 insertions(+), 1680 deletions(-) diff --git a/rtl/dos/dos.pp b/rtl/dos/dos.pp index 9fd6c440df..e0096afc42 100644 --- a/rtl/dos/dos.pp +++ b/rtl/dos/dos.pp @@ -3,6 +3,8 @@ This file is part of the Free Pascal run time library. Copyright (c) 1993,97 by the Free Pascal development team. + Dos unit for BP7 compatible RTL + See the file COPYING.FPC, included in this distribution, for details about the copyright. @@ -68,9 +70,7 @@ Type {$i filerec.inc} {$i textrec.inc} -{$PACKRECORDS 1} - - DateTime = record + DateTime = packed record Year, Month, Day, @@ -79,8 +79,9 @@ Type Sec : word; End; -{$IFDEF GO32V2} - searchrec = record +{$ifdef GO32V2} + + searchrec = packed record fill : array[1..21] of byte; attr : byte; time : longint; @@ -92,7 +93,8 @@ Type Registers = Go32.Registers; {$ELSE} - searchrec = record + + searchrec = packed record fill : array[1..21] of byte; attr : byte; time : longint; @@ -101,7 +103,7 @@ Type name : string[15]; { the same size as declared by (DJ GNU C) } end; - registers = record + registers = packed record case i : integer of 0 : (ax,f1,bx,f2,cx,f3,dx,f4,bp,f5,si,f51,di,f6,ds,f7,es,f8,flags,fs,gs : word); 1 : (al,ah,f9,f10,bl,bh,f11,f12,cl,ch,f13,f14,dl,dh : byte); @@ -109,8 +111,6 @@ Type end; {$endif GO32V1} -{$PACKRECORDS 2} - Var DosError : integer; @@ -249,95 +249,99 @@ var end; {$endif GO32V2} - procedure msdos(var regs : registers); - begin - intr($21,regs); - end; +procedure msdos(var regs : registers); +begin + intr($21,regs); +end; + {****************************************************************************** --- Info / Date / Time --- ******************************************************************************} - function dosversion : word; - begin - dosregs.ax:=$3000; - msdos(dosregs); - dosversion:=dosregs.ax; - end; +function dosversion : word; +begin + dosregs.ax:=$3000; + msdos(dosregs); + dosversion:=dosregs.ax; +end; - procedure getdate(var year,month,mday,wday : word); - begin - dosregs.ax:=$2a00; - msdos(dosregs); - wday:=dosregs.al; - year:=dosregs.cx; - month:=dosregs.dh; - mday:=dosregs.dl; - end; - procedure setdate(year,month,day : word); - begin - dosregs.cx:=year; - dosregs.dh:=month; - dosregs.dl:=day; - dosregs.ah:=$2b; - msdos(dosregs); - LoadDosError; - end; +procedure getdate(var year,month,mday,wday : word); +begin + dosregs.ax:=$2a00; + msdos(dosregs); + wday:=dosregs.al; + year:=dosregs.cx; + month:=dosregs.dh; + mday:=dosregs.dl; +end; - procedure gettime(var hour,minute,second,sec100 : word); - begin - dosregs.ah:=$2c; - msdos(dosregs); - hour:=dosregs.ch; - minute:=dosregs.cl; - second:=dosregs.dh; - sec100:=dosregs.dl; - end; - procedure settime(hour,minute,second,sec100 : word); - begin - dosregs.ch:=hour; - dosregs.cl:=minute; - dosregs.dh:=second; - dosregs.dl:=sec100; - dosregs.ah:=$2d; - msdos(dosregs); - LoadDosError; - end; +procedure setdate(year,month,day : word); +begin + dosregs.cx:=year; + dosregs.dh:=month; + dosregs.dl:=day; + dosregs.ah:=$2b; + msdos(dosregs); + LoadDosError; +end; - Procedure packtime(var t : datetime;var p : longint); - Begin - p:=(t.sec shr 1)+(t.min shl 5)+(t.hour shl 11)+(t.day shl 16)+(t.month shl 21)+((t.year-1980) shl 25); - End; - Procedure unpacktime(p : longint;var t : datetime); - Begin - t.sec:=(p and 31) shl 1; - t.min:=(p shr 5) and 63; - t.hour:=(p shr 11) and 31; - t.day:=(p shr 16) and 31; - t.month:=(p shr 21) and 15; - t.year:=(p shr 25)+1980; - End; +procedure gettime(var hour,minute,second,sec100 : word); +begin + dosregs.ah:=$2c; + msdos(dosregs); + hour:=dosregs.ch; + minute:=dosregs.cl; + second:=dosregs.dh; + sec100:=dosregs.dl; +end; + + +procedure settime(hour,minute,second,sec100 : word); +begin + dosregs.ch:=hour; + dosregs.cl:=minute; + dosregs.dh:=second; + dosregs.dl:=sec100; + dosregs.ah:=$2d; + msdos(dosregs); + LoadDosError; +end; + + +Procedure packtime(var t : datetime;var p : longint); +Begin + p:=(t.sec shr 1)+(t.min shl 5)+(t.hour shl 11)+(t.day shl 16)+(t.month shl 21)+((t.year-1980) shl 25); +End; + + +Procedure unpacktime(p : longint;var t : datetime); +Begin + with t do + begin + sec:=(p and 31) shl 1; + min:=(p shr 5) and 63; + hour:=(p shr 11) and 31; + day:=(p shr 16) and 31; + month:=(p shr 21) and 15; + year:=(p shr 25)+1980; + end; +End; + {****************************************************************************** --- Exec --- ******************************************************************************} - var - lastdosexitcode : word; +var + lastdosexitcode : word; {$ifdef GO32V2} - { this code is just the most basic part of dosexec.c from - the djgpp code } - - procedure exec(const path : pathstr;const comline : comstr); - - procedure do_system(p,c : string); - - { +{ Table 0931 Format of EXEC parameter block for AL=00h,01h,04h: Offset Size Description @@ -350,222 +354,224 @@ var 0Eh DWORD (AL=01h) will hold subprogram's initial SS:SP on return 12h DWORD (AL=01h) will hold entry point (CS:IP) on return INT 21 4B-- - } +} - type - realptr = record - ofs,seg : word; - end; +procedure exec(const path : pathstr;const comline : comstr); +type + realptr = packed record + ofs,seg : word; + end; + texecblock = packed record + envseg : word; + comtail : realptr; + firstFCB : realptr; + secondFCB : realptr; + iniStack : realptr; + iniCSIP : realptr; + end; +var + current_dos_buffer_pos, + arg_ofs, + i,la_env, + la_p,la_c,la_e, + fcb1_la,fcb2_la : longint; + execblock : texecblock; + c,p : string; - texecblock = record - envseg : word; - comtail : realptr; - firstFCB : realptr; - secondFCB : realptr; - iniStack : realptr; - iniCSIP : realptr; - end; + function paste_to_dos(src : string) : boolean; + var + c : array[0..255] of char; + begin + paste_to_dos:=false; + if current_dos_buffer_pos+length(src)+1>transfer_buffer+tb_size then + RunError(217); + move(src[1],c[0],length(src)); + c[length(src)]:=#0; + seg_move(get_ds,longint(@c),dosmemselector,current_dos_buffer_pos,length(src)+1); + current_dos_buffer_pos:=current_dos_buffer_pos+length(src)+1; + paste_to_dos:=true; + end; - var current_dos_buffer_pos : longint; - function paste_to_dos(src : string) : boolean; - var c : array[0..255] of char; - begin - paste_to_dos:=false; - if current_dos_buffer_pos+length(src)+1>transfer_buffer+tb_size then - RunError(217); - move(src[1],c[0],length(src)); - c[length(src)]:=#0; - seg_move(get_ds,longint(@c),dosmemselector,current_dos_buffer_pos,length(src)+1); - current_dos_buffer_pos:=current_dos_buffer_pos+length(src)+1; - paste_to_dos:=true; - end; - var - i,la_env,la_p,la_c,la_e,fcb1_la,fcb2_la : longint; - arg_ofs : longint; - execblock : texecblock; - - begin - la_env:=transfer_buffer; - while (la_env mod 16)<>0 do inc(la_env); - current_dos_buffer_pos:=la_env; - for i:=1 to envcount do - begin - paste_to_dos(envstr(i)); - end; - paste_to_dos(''); { adds a double zero at the end } - { allow slash as backslash } - for i:=1 to length(p) do - if p[i]='/' then p[i]:='\'; - la_p:=current_dos_buffer_pos; - paste_to_dos(p); - la_c:=current_dos_buffer_pos; - paste_to_dos(c); - la_e:=current_dos_buffer_pos; - fcb1_la:=la_e; - la_e:=la_e+16; - fcb2_la:=la_e; - la_e:=la_e+16; - { allocate FCB see dosexec code } - dosregs.ax:=$2901; - arg_ofs:=1; - while (c[arg_ofs]=' ') or (c[arg_ofs]=#9) do inc(arg_ofs); - dosregs.ds:=(la_c+arg_ofs) div 16; - dosregs.si:=(la_c+arg_ofs) mod 16; - dosregs.es:=fcb1_la div 16; - dosregs.di:=fcb1_la mod 16; - msdos(dosregs); - repeat - inc(arg_ofs); - until (c[arg_ofs]=' ') or - (c[arg_ofs]=#9) or - (c[arg_ofs]=#13); - if c[arg_ofs]<>#13 then - begin - inc(arg_ofs); - while (c[arg_ofs]=' ') or (c[arg_ofs]=#9) do inc(arg_ofs); - end; - { allocate second FCB see dosexec code } - dosregs.ax:=$2901; - dosregs.ds:=(la_c+arg_ofs) div 16; - dosregs.si:=(la_c+arg_ofs) mod 16; - dosregs.es:=fcb2_la div 16; - dosregs.di:=fcb2_la mod 16; - msdos(dosregs); - with execblock do - begin - envseg:=la_env div 16; - comtail.seg:=la_c div 16; - comtail.ofs:=la_c mod 16; - firstFCB.seg:=fcb1_la div 16; - firstFCB.ofs:=fcb1_la mod 16; - secondFCB.seg:=fcb2_la div 16; - secondFCB.ofs:=fcb2_la mod 16; - end; - seg_move(get_ds,longint(@execblock),dosmemselector,la_e,sizeof(texecblock)); - dosregs.edx:=la_p mod 16; - dosregs.ds:=la_p div 16; - dosregs.ebx:=la_e mod 16; - dosregs.es:=la_e div 16; - dosregs.ax:=$4b00; - msdos(dosregs); - LoadDosError; - if DosError=0 then - begin - dosregs.ax:=$4d00; - msdos(dosregs); - LastDosExitCode:=DosRegs.al - end - else - LastDosExitCode:=0; - end; - - { var - p,c : array[0..255] of char; } - var c : string; - begin - doserror:=0; - { move(path[1],p,length(path)); - p[length(path)]:=#0; } - move(comline[0],c[1],length(comline)+1); - c[length(comline)+2]:=#13; - c[0]:=char(length(comline)+2); - do_system(path,c); - end; +begin +{ create command line } + move(comline[0],c[1],length(comline)+1); + c[length(comline)+2]:=#13; + c[0]:=char(length(comline)+2); +{ create path } + p:=path; + for i:=1 to length(p) do + if p[i]='/' then + p[i]:='\'; +{ create buffer } + la_env:=transfer_buffer; + while (la_env and 15)<>0 do + inc(la_env); + current_dos_buffer_pos:=la_env; +{ copy environment } + for i:=1 to envcount do + paste_to_dos(envstr(i)); + paste_to_dos(''); { adds a double zero at the end } +{ allow slash as backslash } + la_p:=current_dos_buffer_pos; + paste_to_dos(p); + la_c:=current_dos_buffer_pos; + paste_to_dos(c); + la_e:=current_dos_buffer_pos; + fcb1_la:=la_e; + la_e:=la_e+16; + fcb2_la:=la_e; + la_e:=la_e+16; +{ allocate FCB see dosexec code } + arg_ofs:=1; + while (c[arg_ofs] in [' ',#9]) do + inc(arg_ofs); + dosregs.ax:=$2901; + dosregs.ds:=(la_c+arg_ofs) shr 4; + dosregs.esi:=(la_c+arg_ofs) and 15; + dosregs.es:=fcb1_la shr 4; + dosregs.edi:=fcb1_la and 15; + msdos(dosregs); +{ allocate second FCB see dosexec code } + repeat + inc(arg_ofs); + until (c[arg_ofs] in [' ',#9,#13]); + if c[arg_ofs]<>#13 then + begin + repeat + inc(arg_ofs); + until not (c[arg_ofs] in [' ',#9]); + end; + dosregs.ax:=$2901; + dosregs.ds:=(la_c+arg_ofs) shr 4; + dosregs.si:=(la_c+arg_ofs) and 15; + dosregs.es:=fcb2_la shr 4; + dosregs.di:=fcb2_la and 15; + msdos(dosregs); + with execblock do + begin + envseg:=la_env shr 4; + comtail.seg:=la_c shr 4; + comtail.ofs:=la_c and 15; + firstFCB.seg:=fcb1_la shr 4; + firstFCB.ofs:=fcb1_la and 15; + secondFCB.seg:=fcb2_la shr 4; + secondFCB.ofs:=fcb2_la and 15; + end; + seg_move(get_ds,longint(@execblock),dosmemselector,la_e,sizeof(texecblock)); + dosregs.edx:=la_p and 15; + dosregs.ds:=la_p shr 4; + dosregs.ebx:=la_e and 15; + dosregs.es:=la_e shr 4; + dosregs.ax:=$4b00; + msdos(dosregs); + LoadDosError; + if DosError=0 then + begin + dosregs.ax:=$4d00; + msdos(dosregs); + LastDosExitCode:=DosRegs.al + end + else + LastDosExitCode:=0; +end; {$else GO32V2} - procedure exec(const path : pathstr;const comline : comstr); +procedure exec(const path : pathstr;const comline : comstr); +var + i : longint; + b : array[0..255] of char; +begin + doserror:=0; + for i:=1to length(path) do + if path[i]='/' then + b[i-1]:='\' + else + b[i-1]:=path[i]; + b[i]:=' '; + inc(i); + move(comline[1],b[i],length(comline)); + inc(i,length(comline)); + b[i]:=#0; + asm + leal b,%ebx + movw $0xff07,%ax + int $0x21 + movw %ax,_LASTDOSEXITCODE + end; +end; - procedure do_system(p : pchar); - begin - asm - movl 12(%ebp),%ebx - movw $0xff07,%ax - int $0x21 - movw %ax,_LASTDOSEXITCODE - end; - end; +{$endif} - var - i : longint; - execute : string; - b : array[0..255] of char; - begin - doserror:=0; - execute:=path+' '+comline; - { allow slash as backslash for the program name only } - for i:=1 to length(path) do - if execute[i]='/' then execute[i]:='\'; - move(execute[1],b,length(execute)); - b[length(execute)]:=#0; - do_system(b); - end; +function dosexitcode : word; +begin + dosexitcode:=lastdosexitcode; +end; -{$endif GO32V2} - function dosexitcode : word; - begin - dosexitcode:=lastdosexitcode; - end; +procedure getcbreak(var breakvalue : boolean); +begin + dosregs.ax:=$3300; + msdos(dosregs); + breakvalue:=dosregs.dl<>0; +end; - procedure getcbreak(var breakvalue : boolean); - begin - dosregs.ax:=$3300; - msdos(dosregs); - breakvalue:=dosregs.dl<>0; - end; - procedure setcbreak(breakvalue : boolean); - begin - dosregs.ax:=$3301; - dosregs.dl:=ord(breakvalue); - msdos(dosregs); - end; +procedure setcbreak(breakvalue : boolean); +begin + dosregs.ax:=$3301; + dosregs.dl:=ord(breakvalue); + msdos(dosregs); +end; - procedure getverify(var verify : boolean); - begin - dosregs.ah:=$54; - msdos(dosregs); - verify:=dosregs.al<>0; - end; - procedure setverify(verify : boolean); - begin - dosregs.ah:=$2e; - dosregs.al:=ord(verify); - msdos(dosregs); - end; +procedure getverify(var verify : boolean); +begin + dosregs.ah:=$54; + msdos(dosregs); + verify:=dosregs.al<>0; +end; + + +procedure setverify(verify : boolean); +begin + dosregs.ah:=$2e; + dosregs.al:=ord(verify); + msdos(dosregs); +end; + {****************************************************************************** --- Disk --- ******************************************************************************} - function diskfree(drive : byte) : longint; - begin - dosregs.dl:=drive; - dosregs.ah:=$36; - msdos(dosregs); - if dosregs.ax<>$FFFF then - diskfree:=dosregs.ax*dosregs.bx*dosregs.cx - else - diskfree:=-1; - end; +function diskfree(drive : byte) : longint; +begin + dosregs.dl:=drive; + dosregs.ah:=$36; + msdos(dosregs); + if dosregs.ax<>$FFFF then + diskfree:=dosregs.ax*dosregs.bx*dosregs.cx + else + diskfree:=-1; +end; - function disksize(drive : byte) : longint; - begin - dosregs.dl:=drive; - dosregs.ah:=$36; - msdos(dosregs); - if dosregs.ax<>$FFFF then - disksize:=dosregs.ax*dosregs.cx*dosregs.dx - else - disksize:=-1; - end; +function disksize(drive : byte) : longint; +begin + dosregs.dl:=drive; + dosregs.ah:=$36; + msdos(dosregs); + if dosregs.ax<>$FFFF then + disksize:=dosregs.ax*dosregs.cx*dosregs.dx + else + disksize:=-1; +end; + {****************************************************************************** - --- Findfirst FindNext --- + --- Findfirst FindNext --- ******************************************************************************} procedure searchrec2dossearchrec(var f : searchrec); @@ -814,10 +820,13 @@ var {Now remove also all references to '\..\' + of course previous dirs..} repeat i:=pos('\..\',pa); - if i<>0 then j:=i-1; - while (j>1) and (pa[j]<>'\') do - dec (j); - delete (pa,j,i-j+3); + if i<>0 then + begin + j:=i-1; + while (j>1) and (pa[j]<>'\') do + dec (j); + delete (pa,j,i-j+3); + end; until i=0; {Remove End . and \} if (length(pa)>0) and (pa[length(pa)]='.') then @@ -866,8 +875,6 @@ var end; end; -{$ifdef GO32V2} - procedure getftime(var f;var time : longint); begin dosregs.bx:=textrec(f).handle; @@ -887,109 +894,100 @@ var doserror:=dosregs.al; end; - procedure getfattr(var f;var attr : word); - begin - copytodos(filerec(f).name,strlen(filerec(f).name)+1); - dosregs.ax:=$4300; - dosregs.edx:=transfer_buffer and 15; - dosregs.ds:=transfer_buffer shr 4; - msdos(dosregs); - LoadDosError; - Attr:=dosregs.cx; - end; - procedure setfattr(var f;attr : word); - begin - copytodos(filerec(f).name,strlen(filerec(f).name)+1); - dosregs.ax:=$4301; - dosregs.edx:=transfer_buffer mod 16; - dosregs.ds:=transfer_buffer div 16; - dosregs.cx:=attr; - msdos(dosregs); - LoadDosError; - end; +procedure getfattr(var f;var attr : word); +{$ifndef GO32V2} +var + n : array[0..255] of char; +{$endif} +begin +{$ifdef GO32V2} + copytodos(filerec(f).name,strlen(filerec(f).name)+1); + dosregs.edx:=transfer_buffer and 15; + dosregs.ds:=transfer_buffer shr 4; +{$else} + strpcopy(n,filerec(f).name); + dosregs.edx:=longint(@n); +{$endif} + dosregs.ax:=$4300; + msdos(dosregs); + LoadDosError; + Attr:=dosregs.cx; +end; -{$else GO32V2} - procedure getfattr(var f;var attr : word); - var - n : array[0..255] of char; - r : registers; - begin - strpcopy(n,filerec(f).name); - dosregs.ax:=$4300; - dosregs.edx:=longint(@n); - msdos(dosregs); - LoadDosError; - attr:=dosregs.cx; - end; - - procedure setfattr(var f;attr : word); - var - n : array[0..255] of char; - r : registers; - begin - strpcopy(n,filerec(f).name); - dosregs.ax:=$4301; - dosregs.edx:=longint(@n); - dosregs.cx:=attr; - msdos(dosregs); - LoadDosError; - end; - -{$endif GO32V2} +procedure setfattr(var f;attr : word); +{$ifndef GO32V2} +var + n : array[0..255] of char; +{$endif} +begin +{$ifdef GO32V2} + copytodos(filerec(f).name,strlen(filerec(f).name)+1); + dosregs.edx:=transfer_buffer mod 16; + dosregs.ds:=transfer_buffer div 16; +{$else} + strpcopy(n,filerec(f).name); + dosregs.edx:=longint(@n); +{$endif} + dosregs.ax:=$4301; + dosregs.cx:=attr; + msdos(dosregs); + LoadDosError; +end; {****************************************************************************** --- Environment --- ******************************************************************************} - function envcount : longint; - var - hp : ppchar; - begin - hp:=envp; - envcount:=0; - while assigned(hp^) do - begin - inc(envcount); - hp:=hp+4; - end; - end; +function envcount : longint; +var + hp : ppchar; +begin + hp:=envp; + envcount:=0; + while assigned(hp^) do + begin + inc(envcount); + hp:=hp+4; + end; +end; - function envstr(index : integer) : string; - begin - if (index<=0) or (index>envcount) then - begin - envstr:=''; - exit; - end; - envstr:=strpas(ppchar(envp+4*(index-1))^); - end; +function envstr(index : integer) : string; +begin + if (index<=0) or (index>envcount) then + begin + envstr:=''; + exit; + end; + envstr:=strpas(ppchar(envp+4*(index-1))^); +end; - Function GetEnv(envvar: string): string; - var - hp : ppchar; - hs : string; - eqpos : longint; - begin - envvar:=upcase(envvar); - hp:=envp; - getenv:=''; - while assigned(hp^) do - begin - hs:=strpas(hp^); - eqpos:=pos('=',hs); - if copy(hs,1,eqpos-1)=envvar then - begin - getenv:=copy(hs,eqpos+1,255); - exit; - end; - hp:=hp+4; - end; - end; +Function GetEnv(envvar: string): string; +var + hp : ppchar; + hs : string; + eqpos : longint; +begin + envvar:=upcase(envvar); + hp:=envp; + getenv:=''; + while assigned(hp^) do + begin + hs:=strpas(hp^); + eqpos:=pos('=',hs); + if copy(hs,1,eqpos-1)=envvar then + begin + getenv:=copy(hs,eqpos+1,255); + exit; + end; + hp:=hp+4; + end; +end; + {****************************************************************************** --- Not Supported --- @@ -1011,7 +1009,12 @@ End; end. { $Log$ - Revision 1.3 1998-05-21 19:30:47 peter + Revision 1.4 1998-05-22 00:39:22 peter + * go32v1, go32v2 recompiles with the new objects + * remake3 works again with go32v2 + - removed some "optimizes" from daniel which were wrong + + Revision 1.3 1998/05/21 19:30:47 peter * objects compiles for linux + assign(pchar), assign(char), rename(pchar), rename(char) * fixed read_text_as_array diff --git a/rtl/dos/go32v1/makefile b/rtl/dos/go32v1/makefile index ac09313047..88172d0a9d 100644 --- a/rtl/dos/go32v1/makefile +++ b/rtl/dos/go32v1/makefile @@ -86,13 +86,13 @@ PPI=../ppi include $(CFG)/makefile.cfg # Get the system independent include file names. -# This will set the following variables : +# This will set the following variables : # SYSINCNAMES include $(INC)/makefile.inc SYSINCDEPS=$(addprefix $(INC)/,$(SYSINCNAMES)) # Get the processor dependent include file names. -# This will set the following variables : +# This will set the following variables : # CPUINCNAMES include $(PROCINC)/makefile.cpu SYSCPUDEPS=$(addprefix $(PROCINC)/,$(CPUINCNAMES)) @@ -198,15 +198,15 @@ dos$(PPUEXT) : ../dos.pp $(INC)/filerec.inc $(INC)/textrec.inc \ go32$(PPUEXT) strings$(PPUEXT) $(SYSTEMPPU) $(COPY) ../dos.pp . $(PP) $(OPT) dos $(REDIR) - $(DEL) dos.pp + $(DEL) dos.pp crt$(PPUEXT) : ../crt.pp $(INC)/textrec.inc go32$(PPUEXT) $(SYSTEMPPU) $(COPY) ../crt.pp . $(PP) $(OPT) crt $(REDIR) $(DEL) crt.pp -objects$(PPUEXT) : ../objects.pp $(SYSTEMPPU) - $(COPY) ../objects.pp . +objects$(PPUEXT) : $(INC)/objects.pp objinc.inc $(SYSTEMPPU) + $(COPY) $(INC)/objects.pp . $(PP) $(OPT) objects.pp $(REDIR) $(DEL) objects.pp @@ -234,15 +234,15 @@ mouse$(PPUEXT) : ../mouse.pp $(SYSTEMPPU) $(PP) $(OPT) mouse.pp $(REDIR) $(DEL) mouse.pp -getopts$(PPUEXT) : $(PROCINC)/getopts.pp $(SYSTEMPPU) - $(COPY) $(PROCINC)/getopts.pp . +getopts$(PPUEXT) : $(INC)/getopts.pp $(SYSTEMPPU) + $(COPY) $(INC)/getopts.pp . $(PP) $(OPT) getopts.pp $(REDIR) $(DEL) getopts.pp -graph$(PPUEXT) : ../graph.pp go32$(PPUEXT) $(SYSTEMPPU) mmx$(PPUEXT) \ - $(PPIDEPS) +PPIFILES:=$(wildcard $(PPI)/*.ppi) +graph$(PPUEXT) : ../graph.pp go32$(PPUEXT) $(SYSTEMPPU) mmx$(PPUEXT) $(PPIFILES) $(COPY) ../graph.pp . - $(PP) $(OPT) -Up$(PPI) graph $(REDIR) + $(PP) $(OPT) -I$(PPI) graph $(REDIR) $(DEL) graph.pp diff --git a/rtl/dos/go32v1/os.inc b/rtl/dos/go32v1/os.inc index fd2f5a14a2..e920a87a60 100644 --- a/rtl/dos/go32v1/os.inc +++ b/rtl/dos/go32v1/os.inc @@ -11,7 +11,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. **********************************************************************} -{$define dos} +{$define go32v1} {$undef go32v2} {$undef os2} {$undef linux} @@ -19,27 +19,9 @@ { $Log$ - Revision 1.1 1998-03-25 11:18:41 root - Initial revision + Revision 1.2 1998-05-22 00:39:31 peter + * go32v1, go32v2 recompiles with the new objects + * remake3 works again with go32v2 + - removed some "optimizes" from daniel which were wrong - Revision 1.3 1998/01/26 11:57:08 michael - + Added log at the end - - - - Working file: rtl/dos/go32v1/os.inc - description: - ---------------------------- - revision 1.2 - date: 1997/12/01 12:24:05; author: michael; state: Exp; lines: +13 -0 - + added copyright reference in header. - ---------------------------- - revision 1.1 - date: 1997/11/27 08:33:53; author: michael; state: Exp; - Initial revision - ---------------------------- - revision 1.1.1.1 - date: 1997/11/27 08:33:53; author: michael; state: Exp; lines: +0 -0 - FPC RTL CVS start - ============================================================================= } diff --git a/rtl/dos/go32v1/prt0.as b/rtl/dos/go32v1/prt0.as index f9120d9d18..ac08bce0de 100644 --- a/rtl/dos/go32v1/prt0.as +++ b/rtl/dos/go32v1/prt0.as @@ -3,6 +3,8 @@ # This file is part of the Free Pascal run time library. # Copyright (c) 1993,97 by the Free Pascal development team. # +# Go32V1 Startup code +# # See the file COPYING.FPC, included in this distribution, # for details about the copyright. # @@ -11,14 +13,13 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # # ********************************************************************** -#///* -#//** Called as start(argc, argv, envp) -#//*/ -#///* gs:edx points to prog_info structure. All other registers are OBSOLETE -#//** but included for backwards compatibility -#//*/ - - .text +# +# Called as start(argc, argv, envp) +# +# gs:edx points to prog_info structure. All other registers are OBSOLETE +# but included for backwards compatibility +# +.text .globl _start _start: .globl start @@ -36,7 +37,7 @@ start: movw %ds,%ax cmpw %cx,%ax je Lcopy_none -# /* set the right size */ +# set the right size movl $40,U_SYSTEM_GO32_INFO_BLOCK movl %gs:(%edx), %ecx @@ -84,9 +85,9 @@ Lcopy_done: movw U_SYSTEM_GO32_INFO_BLOCK+36,%ax movw %ax,_run_mode -#/* I need a value for the stack bottom, */ -#/* but I don't know how to get it from go32 */ -#/* I suppose the stack is 4Ko long, is this true ? */ +# I need a value for the stack bottom, +# but I don't know how to get it from go32 +# I suppose the stack is 4Ko long, is this true ? movl %esp,%eax subl $0x4000,%eax movl %eax,__stkbottom @@ -94,7 +95,7 @@ Lcopy_done: movw U_SYSTEM_GO32_INFO_BLOCK+26,%ax movw %ax,_core_selector movl U_SYSTEM_GO32_INFO_BLOCK+28,%eax - movl %eax,U_SYSTEM_STUB_INFO + movl %eax,U_SYSTEM_STUB_INFO xorl %esi,%esi xorl %edi,%edi xorl %ebp,%ebp @@ -105,15 +106,16 @@ Lcopy_done: movl %esp,%ebx movl 8(%ebx),%eax movl %eax,_environ - movl %eax,U_SYSTEM_ENVIRON + movl %eax,U_SYSTEM_ENVP movl 4(%ebx),%eax movl %eax,_args + movl %eax,U_SYSTEM_ARGV movl (%ebx),%eax movl %eax,_argc + movl %eax,U_SYSTEM_ARGC call PASCALMAIN - exit_again: movl $0x4c00,%eax int $0x21 @@ -121,23 +123,31 @@ exit_again: ret - .data +.data .globl _argc _argc: .long 0 + .globl _args _args: .long 0 - .globl _run_mode -_run_mode: - .word 0 - .globl _core_selector -_core_selector: - .word 0 + .globl _environ _environ: .long 0 + .globl __stkbottom +__stkbottom: + .long 0 + + .globl _run_mode +_run_mode: + .word 0 + + .globl _core_selector +_core_selector: + .word 0 + .globl ___pid ___pid: .long 42 @@ -155,30 +165,21 @@ _ScreenSecondary: .long 0 .globl __hard_master - .globl __hard_slave - .globl __core_select __hard_master: .byte 0 + + .globl __hard_slave __hard_slave: .byte 0 + + .globl __core_select __core_select: .short 0 - .globl __stkbottom -__stkbottom: - .long 0 -# .globl U_SYSTEM_GO32_INFO_BLOCK -# U_SYSTEM_GO32_INFO_BLOCK: -# .long __go32_end - U_SYSTEM_GO32_INFO_BLOCK #//* size */ -# .long 0 #//* offs 4 linear_address_of_primary_screen; */ -# .long 0 #//* offs 8 linear_address_of_secondary_screen; */ -# .long 0 #//* offs 12 linear_address_of_transfer_buffer; */ -# .long 0 #//* offs 16 size_of_transfer_buffer; >= 4k */ -# .long 0 #//* offs 20 pid; */ -# .byte 0 #//* offs 24 u_char master_interrupt_controller_base; */ -# .byte 0 #//* offs 25 u_char slave_interrupt_controller_base; */ -# .word 0 #//* offs 26 u_short selector_for_linear_memory; */ -# .long 0 #//* offs 28 u_long linear_address_of_stub_info_structure; */ -# .long 0 #//* offs 32 u_long linear_address_of_original_psp; */ -# .word 0 #//* offs 36 u_short run_mode; */ -# .word 0 #//* offs 38 u_short run_mode_info; */ -#__go32_end: +# +# $Log$ +# Revision 1.3 1998-05-22 00:39:32 peter +# * go32v1, go32v2 recompiles with the new objects +# * remake3 works again with go32v2 +# - removed some "optimizes" from daniel which were wrong +# +# diff --git a/rtl/dos/go32v1/system.pp b/rtl/dos/go32v1/system.pp index ce3225b293..8a55386b99 100644 --- a/rtl/dos/go32v1/system.pp +++ b/rtl/dos/go32v1/system.pp @@ -12,30 +12,45 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. **********************************************************************} - -{ system unit for go32v1 } -{$define DOS} unit system; +interface + +{ no stack check in system } +{$S-} {$I os.inc} - interface +{ include system-independent routine headers } - { die betriebssystemunabhangigen Deklarationen einfuegen: } +{$I systemh.inc} - {$I systemh.inc} +{ include heap support headers } - {$I heaph.inc} +{$I heaph.inc} const - UnusedHandle=$ffff; - StdInputHandle=0; - StdOutputHandle=1; - StdErrorHandle=2; +{ Default filehandles } + UnusedHandle = $ffff; + StdInputHandle = 0; + StdOutputHandle = 1; + StdErrorHandle = 2; + +{ Default memory segments (Tp7 compatibility) } + seg0040 = $0040; + segA000 = $A000; + segB000 = $B000; + segB800 = $B800; + +var +{ C-compatible arguments and environment } + argc : longint; + argv : ppchar; + envp : ppchar; type -{$PACKRECORDS 1} - t_stub_info = record +{ Dos Extender info } + p_stub_info = ^t_stub_info; + t_stub_info = packed record magic : array[0..15] of char; size : longint; minstack : longint; @@ -50,49 +65,47 @@ type basename : array[0..7] of char; argv0 : array [0..15] of char; dpmi_server : array [0..15] of char; - end; - p_stub_info = ^t_stub_info; + end; - t_go32_info_block = record - size_of_this_structure_in_bytes : longint; {offset 0} - linear_address_of_primary_screen : longint; {offset 4} + t_go32_info_block = packed record + size_of_this_structure_in_bytes : longint; {offset 0} + linear_address_of_primary_screen : longint; {offset 4} linear_address_of_secondary_screen : longint; {offset 8} - linear_address_of_transfer_buffer : longint; {offset 12} - size_of_transfer_buffer : longint; {offset 16} - pid : longint; {offset 20} - master_interrupt_controller_base : byte; {offset 24} - slave_interrupt_controller_base : byte; {offset 25} - selector_for_linear_memory : word; {offset 26} + linear_address_of_transfer_buffer : longint; {offset 12} + size_of_transfer_buffer : longint; {offset 16} + pid : longint; {offset 20} + master_interrupt_controller_base : byte; {offset 24} + slave_interrupt_controller_base : byte; {offset 25} + selector_for_linear_memory : word; {offset 26} linear_address_of_stub_info_structure : longint; {offset 28} - linear_address_of_original_psp : longint; {offset 32} - run_mode : word; {offset 36} - run_mode_info : word; {offset 38} - end; -{$PACKRECORDS NORMAL} + linear_address_of_original_psp : longint; {offset 32} + run_mode : word; {offset 36} + run_mode_info : word; {offset 38} + end; var stub_info : p_stub_info; go32_info_block : t_go32_info_block; - environ : ppchar; - implementation +{ Needed for CRT unit } +function do_read(h,addr,len : longint) : longint; - { include system independent routines } - {$I system.inc} +implementation -{$S-} - procedure st1(stack_size : longint);[public,alias: 'STACKCHECK']; +{ include system independent routines } - begin - { called when trying to get local stack } - { if the compiler directive $S is set } - { this function must preserve esi !!!! } - { because esi is set by the calling } - { proc for methods } - { it must preserve all registers !! } +{$I system.inc} - asm +procedure int_stackcheck(stack_size:longint);[public,alias: 'STACKCHECK']; +begin +{ called when trying to get local stack + if the compiler directive $S is set + this function must preserve esi !!!! + because esi is set by the calling + proc for methods + it must preserve all registers !! } + asm pushl %eax pushl %ebx movl stack_size,%ebx @@ -116,88 +129,62 @@ var { can be usefull for error recovery !! } popl %ebx popl %eax - end['EAX','EBX']; - RunError(202); - { this needs a local variable } - { so the function called itself !! } - { Writeln('low in stack '); - RunError(202); } - end; + end['EAX','EBX']; + RunError(202); +end; - procedure halt(errnum : byte); - begin - do_exit; - flush(stderr); - asm - movl $0x4c00,%eax - movb 8(%ebp),%al - int $0x21 - end; - end; +{$I386_ATT} - function paramcount : longint; +procedure halt(errnum : byte); +begin + do_exit; + flush(stderr); + asm + movl $0x4c00,%eax + movb errnum,%al + int $0x21 + end; +end; - begin - asm - movl _argc,%eax - decl %eax - leave - ret - end ['EAX']; - end; - function paramstr(l : longint) : string; +function paramcount : longint; +begin + paramcount := argc - 1; +end; - function args : pointer; - begin - asm - movl _args,%eax - leave - ret - end ['EAX']; - end; +function paramstr(l : longint) : string; +begin + if (l>=0) and (l+1<=argc) then + paramstr:=strpas(argv[l]) + else + paramstr:=''; +end; - var - p : ^pchar; - begin - if (l>=0) and (l<=paramcount) then - begin - p:=args; - paramstr:=strpas(p[l]); - end - else paramstr:=''; - end; +procedure randomize;assembler; +asm + movb $0x2c,%ah + int $0x21 + shll $16,%ecx + movw %dx,%cx + movl %ecx,randseed +end; - procedure randomize; - var - hl : longint; - begin - asm - movb $0x2c,%ah - int $0x21 - movw %cx,-4(%ebp) - movw %dx,-2(%ebp) - end; - randseed:=hl; - end; +{***************************************************************************** + Heap Management +*****************************************************************************} -{ use standard heap management } -{ sbrk function of go32v1 } - function Sbrk(size : longint) : longint; - - begin - asm - movl size,%ebx - movl $0x4a01,%eax - int $0x21 - movl %eax,__RESULT - end; - end; +function Sbrk(size : longint) : longint;assembler; +asm + movl size,%ebx + movl $0x4a01,%eax + int $0x21 +end; +{ include standard heap management } {$I heap.inc} @@ -215,15 +202,13 @@ begin end; -procedure do_close(h : longint); -begin - asm - movl 8(%ebp),%ebx - movb $0x3e,%ah - pushl %ebp - intl $0x21 - popl %ebp - end; +procedure do_close(h : longint);assembler; +asm + movl h,%ebx + movb $0x3e,%ah + pushl %ebp + intl $0x21 + popl %ebp end; @@ -231,14 +216,14 @@ procedure do_erase(p : pchar); begin AllowSlash(p); asm - movl 8(%ebp),%edx - movb $0x41,%ah - pushl %ebp - int $0x21 - popl %ebp - jnc .LERASE1 - movw %ax,U_SYSTEM_INOUTRES; - .LERASE1: + movl p,%edx + movb $0x41,%ah + pushl %ebp + int $0x21 + popl %ebp + jnc .LERASE1 + movw %ax,inoutres +.LERASE1: end; end; @@ -248,159 +233,135 @@ begin AllowSlash(p1); AllowSlash(p2); asm - movl 8(%ebp),%edx - movl 12(%ebp),%edi - movb $0x56,%ah - pushl %ebp - int $0x21 - popl %ebp - jnc .LRENAME1 - movw %ax,U_SYSTEM_INOUTRES; - .LRENAME1: + movl p1,%edx + movl p2,%edi + movb $0x56,%ah + pushl %ebp + int $0x21 + popl %ebp + jnc .LRENAME1 + movw %ax,inoutres +.LRENAME1: end; end; -function do_write(h,addr,len : longint) : longint; -begin - asm - movl 16(%ebp),%ecx - movl 12(%ebp),%edx - movl 8(%ebp),%ebx - movb $0x40,%ah - int $0x21 - jnc .LDOSWRITE1 - movw %ax,U_SYSTEM_INOUTRES; - .LDOSWRITE1: - movl %eax,-4(%ebp) - end; +function do_write(h,addr,len : longint) : longint;assembler; +asm + movl len,%ecx + movl addr,%edx + movl h,%ebx + movb $0x40,%ah + int $0x21 + jnc .LDOSWRITE1 + movw %ax,inoutres + xorl %eax,%eax +.LDOSWRITE1: end; -function do_read(h,addr,len : longint) : longint; -begin - asm - movl 16(%ebp),%ecx - movl 12(%ebp),%edx - movl 8(%ebp),%ebx - movb $0x3f,%ah - int $0x21 - jnc .LDOSREAD1 - movw %ax,U_SYSTEM_INOUTRES; - xorl %eax,%eax - .LDOSREAD1: - leave - ret $12 - end; +function do_read(h,addr,len : longint) : longint;assembler; +asm + movl len,%ecx + movl addr,%edx + movl h,%ebx + movb $0x3f,%ah + int $0x21 + jnc .LDOSREAD1 + movw %ax,inoutres + xorl %eax,%eax +.LDOSREAD1: end; -function do_filepos(handle : longint) : longint; -begin - asm - movb $0x42,%ah - movb $0x1,%al - movl 8(%ebp),%ebx - xorl %ecx,%ecx - xorl %edx,%edx - pushl %ebp - int $0x21 - popl %ebp - jnc .LDOSFILEPOS1 - movw %ax,U_SYSTEM_INOUTRES; - xorl %eax,%eax - jmp .LDOSFILEPOS2 - .LDOSFILEPOS1: - shll $16,%edx - movzwl %ax,%eax - orl %edx,%eax - .LDOSFILEPOS2: - leave - ret $4 - end; +function do_filepos(handle : longint) : longint;assembler; +asm + movl $0x4201,%eax + movl handle,%ebx + xorl %ecx,%ecx + xorl %edx,%edx + pushl %ebp + int $0x21 + popl %ebp + jnc .LDOSFILEPOS1 + movw %ax,inoutres + xorl %eax,%eax + jmp .LDOSFILEPOS2 +.LDOSFILEPOS1: + shll $16,%edx + movzwl %ax,%eax + orl %edx,%eax +.LDOSFILEPOS2: end; -procedure do_seek(handle,pos : longint); -begin - asm - movl $0x4200,%eax - movl 8(%ebp),%ebx - movl 12(%ebp),%edx - movl %edx,%ecx - shrl $16,%ecx - pushl %ebp - int $0x21 - popl %ebp - jnc .LDOSSEEK1 - movw %ax,U_SYSTEM_INOUTRES; - .LDOSSEEK1: - leave - ret $8 - end; +procedure do_seek(handle,pos : longint);assembler; +asm + movl $0x4200,%eax + movl handle,%ebx + movl pos,%edx + movl %edx,%ecx + shrl $16,%ecx + pushl %ebp + int $0x21 + popl %ebp + jnc .LDOSSEEK1 + movw %ax,inoutres +.LDOSSEEK1: end; -function do_seekend(handle : longint) : longint; -begin - asm - movl $0x4202,%eax - movl 8(%ebp),%ebx - xorl %ecx,%ecx - xorl %edx,%edx - pushl %ebp - int $0x21 - popl %ebp - jnc .Lset_at_end1 - movw %ax,U_SYSTEM_INOUTRES; - xorl %eax,%eax - jmp .Lset_at_end2 - .Lset_at_end1: - shll $16,%edx - movzwl %ax,%eax - orl %edx,%eax - .Lset_at_end2: - leave - ret $4 - end; +function do_seekend(handle : longint) : longint;assembler; +asm + movl $0x4202,%eax + movl handle,%ebx + xorl %ecx,%ecx + xorl %edx,%edx + pushl %ebp + int $0x21 + popl %ebp + jnc .Lset_at_end1 + movw %ax,inoutres + xorl %eax,%eax + jmp .Lset_at_end2 +.Lset_at_end1: + shll $16,%edx + movzwl %ax,%eax + orl %edx,%eax +.Lset_at_end2: end; function do_filesize(handle : longint) : longint; var - aktfilepos : longint; + aktfilepos : longint; begin - aktfilepos:=do_filepos(handle); - do_filesize:=do_seekend(handle); - do_seek(handle,aktfilepos); + aktfilepos:=do_filepos(handle); + do_filesize:=do_seekend(handle); + do_seek(handle,aktfilepos); end; -procedure do_truncate(handle,pos : longint); -begin - asm - movl $0x4200,%eax - movl 8(%ebp),%ebx - movl 12(%ebp),%edx - movl %edx,%ecx - shrl $16,%ecx - pushl %ebp - int $0x21 - popl %ebp - jc .LTruncate1 - movl 8(%ebp),%ebx - movl 12(%ebp),%edx - movl %ebp,%edx - xorl %ecx,%ecx - movb $0x40,%ah - int $0x21 - jnc .LTruncate2 - .LTruncate1: - movw %ax,U_SYSTEM_INOUTRES; - .LTruncate2: - leave - ret $8 - end; +procedure do_truncate(handle,pos : longint);assembler; +asm + movl $0x4200,%eax + movl handle,%ebx + movl pos,%edx + movl %edx,%ecx + shrl $16,%ecx + pushl %ebp + int $0x21 + popl %ebp + jc .LTruncate1 + movl handle,%ebx + movl %ebp,%edx + xorl %ecx,%ecx + movb $0x40,%ah + int $0x21 + jnc .LTruncate2 +.LTruncate1: + movw %ax,inoutres +.LTruncate2: end; @@ -413,7 +374,7 @@ procedure do_open(var f;p:pchar;flags:longint); when (flags and $1000) there is no check for close (needed for textfiles) } var - oflags : longint; + oflags : longint; begin AllowSlash(p); { close first if opened } @@ -465,18 +426,18 @@ begin end; exit; end; - asm - movl $0xff02,%ax - movl -4(%ebp),%ecx - movl 12(%ebp),%ebx - int $0x21 - jnc .LOPEN1 - movw %ax,U_SYSTEM_INOUTRES; - movw $0xffff,%ax - .LOPEN1: - movl 8(%ebp),%edx - movw %ax,(%edx) - end; + asm + movl $0xff02,%eax + movl oflags,%ecx + movl flags,%ebx + int $0x21 + jnc .LOPEN1 + movw %ax,inoutres + movw $0xffff,%ax +.LOPEN1: + movl f,%edx + movw %ax,(%edx) + end; if (flags and $10)<>0 then do_seekend(filerec(f).handle); end; @@ -513,12 +474,12 @@ begin buffer[length(s)]:=#0; AllowSlash(pchar(@buffer)); asm - leal buffer,%edx - movb 8(%ebp),%ah - int $0x21 - jnc .LDOS_DIRS1 - movw %ax,U_SYSTEM_INOUTRES; - .LDOS_DIRS1: + leal buffer,%edx + movb func,%ah + int $0x21 + jnc .LDOS_DIRS1 + movw %ax,inoutres +.LDOS_DIRS1: end; end; @@ -540,9 +501,7 @@ begin DosDir($3b,s); end; -{ thanks to Michael Van Canneyt , } -{ who writes this code } -{ her is a problem if the getdir is called with a pathstr var in dos.pp } + procedure getdir(drivenr : byte;var dir : string); var temp : array[0..255] of char; @@ -550,18 +509,16 @@ var i : byte; begin sof:=pchar(@dir[4]); - { dir[1..3] will contain '[drivenr]:\', but is not } - { supplied by DOS, so we let dos string start at } - { dir[4] } - { Get dir from drivenr : 0=default, 1=A etc... } +{ dir[1..3] will contain '[drivenr]:\', but is not supplied by DOS, + so we let dos string start at dir[4] + Get dir from drivenr : 0=default, 1=A etc } asm - movb drivenr,%dl - movl sof,%esi - mov $0x47,%ah - int $0x21 + movb drivenr,%dl + movl sof,%esi + mov $0x47,%ah + int $0x21 end; -{ Now Dir should be filled with directory in ASCIIZ, } -{ starting from dir[4] } +{ Now Dir should be filled with directory in ASCIIZ starting from dir[4] } dir[0]:=#3; dir[2]:=':'; dir[3]:='\'; @@ -575,7 +532,7 @@ begin dir[0]:=chr(i); inc(i); end; -{ upcase the string (FPKPascal function) } +{ upcase the string } dir:=upcase(dir); if drivenr<>0 then { Drive was supplied. We know it } dir[1]:=chr(65+drivenr-1) @@ -584,10 +541,10 @@ begin { We need to get the current drive from DOS function 19H } { because the drive was the default, which can be unknown } asm - movb $0x19,%ah - int $0x21 - addb $65,%al - movb %al,i + movb $0x19,%ah + int $0x21 + addb $65,%al + movb %al,i end; dir[1]:=chr(i); end; @@ -623,60 +580,11 @@ Begin { Reset IO Error } InOutRes:=0; End. - { $Log$ - Revision 1.2 1998-03-26 12:21:02 peter - * makefile works again - * environ is now defined in system.pp (like go32v2) + Revision 1.3 1998-05-22 00:39:33 peter + * go32v1, go32v2 recompiles with the new objects + * remake3 works again with go32v2 + - removed some "optimizes" from daniel which were wrong - Revision 1.1.1.1 1998/03/25 11:18:41 root - * Restored version - - Revision 1.9 1998/02/14 01:41:35 peter - * fixed unusedhandle bug which was -1 - - Revision 1.8 1998/01/26 11:57:03 michael - + Added log at the end - - - - Working file: rtl/dos/go32v1/system.pp - description: - ---------------------------- - revision 1.7 - date: 1998/01/25 21:53:22; author: peter; state: Exp; lines: +12 -8 - + Universal Handles support for StdIn/StdOut/StdErr - * Updated layout of sysamiga.pas - ---------------------------- - revision 1.6 - date: 1998/01/16 23:10:50; author: florian; state: Exp; lines: +2 -2 - + some tobject stuff - ---------------------------- - revision 1.5 - date: 1998/01/11 02:47:31; author: michael; state: Exp; lines: +384 -507 - * Changed files to use the new filestructure in /inc directory. - (By Peter Vreman) - ---------------------------- - revision 1.4 - date: 1998/01/07 00:05:04; author: michael; state: Exp; lines: +189 -184 - + Final adjustments for a uniform file handling interface. - (From Peter Vreman) - ---------------------------- - revision 1.3 - date: 1998/01/05 16:51:04; author: michael; state: Exp; lines: +18 -46 - + Moved init of heap to heap.inc: INITheap() (From Peter Vreman) - ---------------------------- - revision 1.2 - date: 1997/12/01 12:24:06; author: michael; state: Exp; lines: +12 -3 - + added copyright reference in header. - ---------------------------- - revision 1.1 - date: 1997/11/27 08:33:53; author: michael; state: Exp; - Initial revision - ---------------------------- - revision 1.1.1.1 - date: 1997/11/27 08:33:53; author: michael; state: Exp; lines: +0 -0 - FPC RTL CVS start - ============================================================================= } diff --git a/rtl/dos/go32v2/makefile b/rtl/dos/go32v2/makefile index 81bff0b116..b3d4217788 100644 --- a/rtl/dos/go32v2/makefile +++ b/rtl/dos/go32v2/makefile @@ -200,8 +200,8 @@ crt$(PPUEXT) : ../crt.pp $(INC)/textrec.inc go32$(PPUEXT) $(SYSTEMPPU) $(PP) $(OPT) crt $(REDIR) $(DEL) crt.pp -objects$(PPUEXT) : ../objects.pp $(SYSTEMPPU) - $(COPY) ../objects.pp . +objects$(PPUEXT) : $(INC)/objects.pp $(INC)/platform.inc objinc.inc $(SYSTEMPPU) + $(COPY) $(INC)/objects.pp . $(PP) $(OPT) objects.pp $(REDIR) $(DEL) objects.pp @@ -229,8 +229,8 @@ mouse$(PPUEXT) : ../mouse.pp $(SYSTEMPPU) $(PP) $(OPT) mouse.pp $(REDIR) $(DEL) mouse.pp -getopts$(PPUEXT) : $(PROCINC)/getopts.pp $(SYSTEMPPU) - $(COPY) $(PROCINC)/getopts.pp . +getopts$(PPUEXT) : $(INC)/getopts.pp $(SYSTEMPPU) + $(COPY) $(INC)/getopts.pp . $(PP) $(OPT) getopts.pp $(REDIR) $(DEL) getopts.pp @@ -264,7 +264,12 @@ include $(CFG)/makefile.def # # $Log$ -# Revision 1.8 1998-05-06 11:53:40 peter +# Revision 1.9 1998-05-22 00:39:36 peter +# * go32v1, go32v2 recompiles with the new objects +# * remake3 works again with go32v2 +# - removed some "optimizes" from daniel which were wrong +# +# Revision 1.8 1998/05/06 11:53:40 peter # * update # # diff --git a/rtl/dos/go32v2/v2prt0.as b/rtl/dos/go32v2/v2prt0.as index 85df0fe0b0..e038a6585b 100644 --- a/rtl/dos/go32v2/v2prt0.as +++ b/rtl/dos/go32v2/v2prt0.as @@ -5,15 +5,15 @@ /*****************************************************************************\ * Interface to 32-bit executable (from stub.asm) * - * cs:eip according to COFF header - * ds 32-bit data segment for COFF program - * fs selector for our data segment (fs:0 is stubinfo) - * ss:sp our stack (ss to be freed) - * All unspecified registers have unspecified values in them. + * cs:eip according to COFF header + * ds 32-bit data segment for COFF program + * fs selector for our data segment (fs:0 is stubinfo) + * ss:sp our stack (ss to be freed) + * All unspecified registers have unspecified values in them. \*****************************************************************************/ /* modified by Pierre Muller to become the prt0.s for FPK Pascal */ - .file "v2prt0.s" + .file "v2prt0.s" /* #include "stubinfo.h" */ STUBINFO = 0 @@ -34,15 +34,15 @@ STUBINFO_END = 0x54 -/* .comm __stklen, 4 +/* .comm __stklen, 4 this is added to the compiler so that we can specify the stack size */ .comm __stkbottom,4 - .comm __stubinfo, 4 - .comm ___djgpp_base_address, 4 - .comm ___djgpp_selector_limit, 4 - .comm ___djgpp_stack_limit, 4 - .lcomm sel_buf, 8 + .comm __stubinfo, 4 + .comm ___djgpp_base_address, 4 + .comm ___djgpp_selector_limit, 4 + .comm ___djgpp_stack_limit, 4 + .lcomm sel_buf, 8 /* ___djgpp_ds_alias defined in go32/exceptn.s */ /* inserted at the end of this file */ /* we use a local copy that will be copied to exceptn.s */ @@ -56,12 +56,12 @@ ___v2prt0_ds_alias: address of _djgpp => big troubles That is why I removed the multiblocks Pierre Muller */ - .data + .data /* .ifdef MULTIBLOCK needed anyhow */ ___djgpp_memory_handle_pointer: - .long ___djgpp_memory_handle_list+8 /* Next free, first for stub */ - .comm ___djgpp_memory_handle_list, 2048 /* Enough for 256 handles */ + .long ___djgpp_memory_handle_list+8 /* Next free, first for stub */ + .comm ___djgpp_memory_handle_list, 2048 /* Enough for 256 handles */ /* .endif */ sbrk16_first_byte: @@ -69,212 +69,212 @@ sbrk16_first_byte: sbrk16_last_byte: sbrk16_api_ofs: - .long 0 + .long 0 sbrk16_api_seg: - .word 0 + .word 0 zero: - .long 0 + .long 0 exit16_first_byte: .include "exit16.ah" exit16_last_byte: /* hook_387_emulator: - .long ___emu387_load_hook */ + .long ___emu387_load_hook */ /* this pulls in the ident string, generated in .. */ -/* .long ___libc_ident_string */ +/* .long ___libc_ident_string */ /* this is for when main comes from a library */ - .long _main + .long _main - .text + .text - .globl start + .globl start start: - pushl %ds /* set %es same as %ds */ - popl %es /* push/pop 4 bytes shorter than ax */ + pushl %ds /* set %es same as %ds */ + popl %es /* push/pop 4 bytes shorter than ax */ .if 0 /* we do this in the stub now */ - movl $edata, %edi /* set all BSS bytes to zero */ - movl $end, %ecx - subl %edi, %ecx - xorl %eax, %eax /* Zero fill value */ - shrl $2, %ecx /* div 4 Longwords not bytes */ - cld - rep - stosl + movl $edata, %edi /* set all BSS bytes to zero */ + movl $end, %ecx + subl %edi, %ecx + xorl %eax, %eax /* Zero fill value */ + shrl $2, %ecx /* div 4 Longwords not bytes */ + cld + rep + stosl .endif /* Enable NULL pointer protection if DPMI supports it */ - testb $0x1, __crt0_startup_flags+1 /* include/crt0.h */ - jnz 1f - movl $start, %eax - cmpl $0x1000, %eax - jl 1f - movw $0x507, %ax - .byte 0x64 /* fs: */ - movl STUBINFO_MEMORY_HANDLE, %esi - xorl %ebx, %ebx /* Offset 0 in mem block */ - movl $1, %ecx /* Set one page */ - movl $zero, %edx - int $0x31 /* Make null page uncommitted */ + testb $0x1, __crt0_startup_flags+1 /* include/crt0.h */ + jnz 1f + movl $start, %eax + cmpl $0x1000, %eax + jl 1f + movw $0x507, %ax + .byte 0x64 /* fs: */ + movl STUBINFO_MEMORY_HANDLE, %esi + xorl %ebx, %ebx /* Offset 0 in mem block */ + movl $1, %ecx /* Set one page */ + movl $zero, %edx + int $0x31 /* Make null page uncommitted */ 1: /* Create an alias for DS to be used by real-mode callbacks (exception handler messes with DS itself) */ - movw %ds, %bx - movw $0x000a, %ax - int $0x31 - jnc ds_alias_ok - movb $0x4c, %ah - int $0x21 + movw %ds, %bx + movw $0x000a, %ax + int $0x31 + jnc ds_alias_ok + movb $0x4c, %ah + int $0x21 ds_alias_ok: - movw %ax, ___v2prt0_ds_alias - movl %eax, %ebx - movw $0x0009, %ax - movw %cs, %cx /* get CPL from %cs */ - andl $3, %ecx - shll $5, %ecx /* move it into place */ - orw $0xc093, %cx - int $0x31 /* set access rights for alias */ + movw %ax, ___v2prt0_ds_alias + movl %eax, %ebx + movw $0x0009, %ax + movw %cs, %cx /* get CPL from %cs */ + andl $3, %ecx + shll $5, %ecx /* move it into place */ + orw $0xc093, %cx + int $0x31 /* set access rights for alias */ /* Maybe set our DS limit to 4Gb in size if flag set */ - testb $0x80, __crt0_startup_flags /* include/crt0.h */ - jz 2f - movw $0xffff, %cx - movl %ecx, %edx - movw $0x0008, %ax /* reset alias limit to -1 */ - int $0x31 - movw %cs, %bx - movw $0x0008, %ax /* reset DS limit to -1 */ - int $0x31 - movw %ds, %bx - movw $0x0008, %ax /* reset DS limit to -1 */ - int $0x31 - lsl %ebx, %ebx /* Should be -1 */ - incl %ebx - jz 2f - andb $0x7f, __crt0_startup_flags /* clear it if failure */ + testb $0x80, __crt0_startup_flags /* include/crt0.h */ + jz 2f + movw $0xffff, %cx + movl %ecx, %edx + movw $0x0008, %ax /* reset alias limit to -1 */ + int $0x31 + movw %cs, %bx + movw $0x0008, %ax /* reset DS limit to -1 */ + int $0x31 + movw %ds, %bx + movw $0x0008, %ax /* reset DS limit to -1 */ + int $0x31 + lsl %ebx, %ebx /* Should be -1 */ + incl %ebx + jz 2f + andb $0x7f, __crt0_startup_flags /* clear it if failure */ 2: .ifdef MULTIBLOCK - testb $0x8, __crt0_startup_flags+1 /* include/crt0.h */ - jz 8f + testb $0x8, __crt0_startup_flags+1 /* include/crt0.h */ + jz 8f .endif /* Allocate some DOS memory and copy our sbrk helper into it. */ - movl $sbrk16_first_byte, %esi - movzwl 8(%esi), %ebx - shrl $4, %ebx - movw $0x0100, %ax - int $0x31 - jnc dos_alloc_ok - movb $0x4c, %ah - int $0x21 + movl $sbrk16_first_byte, %esi + movzwl 8(%esi), %ebx + shrl $4, %ebx + movw $0x0100, %ax + int $0x31 + jnc dos_alloc_ok + movb $0x4c, %ah + int $0x21 dos_alloc_ok: - movw %cs, 2(%esi) + movw %cs, 2(%esi) /* store API information */ - movw %ds, 4(%esi) - movw %dx, 6(%esi) + movw %ds, 4(%esi) + movw %dx, 6(%esi) /* selector for allocated block */ - movzwl (%esi), %eax /* calculate API address */ - movl %eax, sbrk16_api_ofs + movzwl (%esi), %eax /* calculate API address */ + movl %eax, sbrk16_api_ofs - pushl %es /* move the data */ - movw %dx, %es - movl $(sbrk16_last_byte - sbrk16_first_byte), %ecx - shrl $2,%ecx - xorl %edi, %edi - cld - rep - movsl - popl %es + pushl %es /* move the data */ + movw %dx, %es + movl $(sbrk16_last_byte - sbrk16_first_byte), %ecx + shrl $2,%ecx + xorl %edi, %edi + cld + rep + movsl + popl %es - movl %edx, %ebx /* dos memory selector */ - movw $0x000b, %ax /* get descriptor */ - movl $sel_buf, %edi - int $0x31 + movl %edx, %ebx /* dos memory selector */ + movw $0x000b, %ax /* get descriptor */ + movl $sel_buf, %edi + int $0x31 - andb $0xbf, sel_buf+6 /* make 16-bit */ - andb $0xf0, sel_buf+5 /* remove old type */ - orb $0x0a, sel_buf+5 /* set new type to code/read */ + andb $0xbf, sel_buf+6 /* make 16-bit */ + andb $0xf0, sel_buf+5 /* remove old type */ + orb $0x0a, sel_buf+5 /* set new type to code/read */ - xorl %eax, %eax /* allocate new selector */ - movw $0x0001, %cx - int $0x31 - movw %ax, sbrk16_api_seg + xorl %eax, %eax /* allocate new selector */ + movw $0x0001, %cx + int $0x31 + movw %ax, sbrk16_api_seg - movl %eax, %ebx - movw $0x000c, %ax /* set descriptor */ - movl $sel_buf, %edi - int $0x31 + movl %eax, %ebx + movw $0x000c, %ax /* set descriptor */ + movl $sel_buf, %edi + int $0x31 .ifdef MULTIBLOCK -8: movl $___djgpp_memory_handle_list+8, %edi - movl %edi, ___djgpp_memory_handle_pointer - xorl %eax, %eax -9: cmpl %eax, (%edi) - je 10f - mov %eax, (%edi) - addl $4, %edi - jmp 9b -10: movw %cs, %bx - movw $0x0006,%ax - int $0x31 - movl %edx,___djgpp_base_address - movw %cx,___djgpp_base_address+2 -.endif /* MULTIBLOCK */ +8: movl $___djgpp_memory_handle_list+8, %edi + movl %edi, ___djgpp_memory_handle_pointer + xorl %eax, %eax +9: cmpl %eax, (%edi) + je 10f + mov %eax, (%edi) + addl $4, %edi + jmp 9b +10: movw %cs, %bx + movw $0x0006,%ax + int $0x31 + movl %edx,___djgpp_base_address + movw %cx,___djgpp_base_address+2 +.endif /* MULTIBLOCK */ /* Initialize the brk/sbrk variables */ -/* movl $end, __what_size_app_thinks_it_is */ - .byte 0x64 /* fs: */ - movl STUBINFO_INITIAL_SIZE, %eax - movl %eax, __what_size_dpmi_thinks_we_are +/* movl $end, __what_size_app_thinks_it_is */ + .byte 0x64 /* fs: */ + movl STUBINFO_INITIAL_SIZE, %eax + movl %eax, __what_size_dpmi_thinks_we_are /* Maybe lock the initial block, expects BX:CX */ - movl %ecx,%ebx - movl %edx,%ecx - addw $4096,%cx /* Skip null page */ - adcl $0,%ebx - subl $4096,%eax - pushl %eax - call lock_memory + movl %ecx,%ebx + movl %edx,%ecx + addw $4096,%cx /* Skip null page */ + adcl $0,%ebx + subl $4096,%eax + pushl %eax + call lock_memory - .byte 0x64 /* fs: */ - movl STUBINFO_MEMORY_HANDLE, %eax - movl %eax, ___djgpp_memory_handle_list + .byte 0x64 /* fs: */ + movl STUBINFO_MEMORY_HANDLE, %eax + movl %eax, ___djgpp_memory_handle_list - .byte 0x64 /* fs: */ /* copy stubinfo into local memory */ - movl STUBINFO_SIZE, %eax - pushl %eax - call ___sbrk - movl %eax, __stubinfo - movl %eax,U_SYSTEM_STUB_INFO - movl %eax, %edi - .byte 0x64 /* fs: */ - movl STUBINFO_SIZE, %ecx - shrl $2, %ecx - xorl %esi, %esi /* Zero */ - pushl %ds - pushl %fs - popl %ds - cld - rep - movsl - popl %ds - movl __stklen, %eax /* get program-requested stack size */ - .byte 0x64 /* fs: */ - movl STUBINFO_MINSTACK, %ecx /* get stub-requested stack size */ - cmpl %ecx, %eax - jge use_stubinfo_stack_size /* use the larger of the two */ - movl %ecx, %eax - movl %eax, __stklen /* store the actual stack length */ + .byte 0x64 /* fs: */ /* copy stubinfo into local memory */ + movl STUBINFO_SIZE, %eax + pushl %eax + call ___sbrk + movl %eax, __stubinfo + movl %eax,U_SYSTEM_STUB_INFO + movl %eax, %edi + .byte 0x64 /* fs: */ + movl STUBINFO_SIZE, %ecx + shrl $2, %ecx + xorl %esi, %esi /* Zero */ + pushl %ds + pushl %fs + popl %ds + cld + rep + movsl + popl %ds + movl __stklen, %eax /* get program-requested stack size */ + .byte 0x64 /* fs: */ + movl STUBINFO_MINSTACK, %ecx /* get stub-requested stack size */ + cmpl %ecx, %eax + jge use_stubinfo_stack_size /* use the larger of the two */ + movl %ecx, %eax + movl %eax, __stklen /* store the actual stack length */ use_stubinfo_stack_size: - pushl %eax - call ___sbrk /* allocate the memory */ - cmpl $-1, %eax - je no_memory - movl %eax, ___djgpp_stack_limit /* Bottom of stack */ + pushl %eax + call ___sbrk /* allocate the memory */ + cmpl $-1, %eax + je no_memory + movl %eax, ___djgpp_stack_limit /* Bottom of stack */ addl $256,%eax movl %eax,__stkbottom /* for stack checks */ movl %eax,U_SYSTEM_STACKBOTTOM @@ -282,56 +282,56 @@ use_stubinfo_stack_size: .ifdef LOCK_BOTTOM_STACK /* test lock one page at bottom of stack to be sure that there is */ /* not stack overflow, as the minimal size is 128 ko 4ko less is not much !! */ - testb $0x1, __crt0_startup_flags+1 /* include/crt0.h */ - jnz 101f /* just to be sure it is not used */ - movl %eax, %ebx /* Offset __djgpp_stack_limit in mem block */ + testb $0x1, __crt0_startup_flags+1 /* include/crt0.h */ + jnz 101f /* just to be sure it is not used */ + movl %eax, %ebx /* Offset __djgpp_stack_limit in mem block */ addl $0xfff,%ebx andl $0xfffff000,%ebx /* page align it */ - movw $0x507, %ax + movw $0x507, %ax .ifdef MULTIBLOCK - movl ___djgpp_memory_handle_pointer-8, %esi /* last memory block */ + movl ___djgpp_memory_handle_pointer-8, %esi /* last memory block */ .else /* not MULTIBLOCK */ - movl ___djgpp_memory_handle_list, %esi /* last memory block */ + movl ___djgpp_memory_handle_list, %esi /* last memory block */ .endif - movl $1, %ecx /* Set one page */ - movl $zero, %edx - int $0x31 /* Make first stack page page uncommitted */ + movl $1, %ecx /* Set one page */ + movl $zero, %edx + int $0x31 /* Make first stack page page uncommitted */ 101: .endif /* LOCK_BOTTOM_STACK */ - movl ___djgpp_stack_limit,%eax /* Bottom of stack */ - addl __stklen, %eax - movw %ds, %dx /* set stack */ - movw %dx, %ss - movl %eax, %esp + movl ___djgpp_stack_limit,%eax /* Bottom of stack */ + addl __stklen, %eax + movw %ds, %dx /* set stack */ + movw %dx, %ss + movl %eax, %esp - xorl %ebp, %ebp -.if 0 /* done in crt1.c */ - .byte 0x64 /* fs: */ /* set up _go32_info_block structure */ - movzwl STUBINFO_MINKEEP, %eax - movl %eax, U_SYSTEM_GO32_INFO_BLOCK+16 /* .size_of_transfer_buffer */ - .byte 0x64 /* fs: */ - movzwl STUBINFO_DS_SEGMENT, %eax - shll $4, %eax - movl %eax, U_SYSTEM_GO32_INFO_BLOCK+12 /* .linear_address_of_transfer_buffer */ - xorl %eax, %eax - movl $1, %ecx - int $0x31 - jc no_selector - movw %ax, U_SYSTEM_GO32_INFO_BLOCK+26 /* .selector_for_linear_memory */ - movl %eax, %ebx - movl $8, %eax - movl $0x0f, %ecx - movw $0xffff, %dx - int $0x31 /* Set limit 1Mb */ + xorl %ebp, %ebp +.if 0 /* done in crt1.c */ + .byte 0x64 /* fs: */ /* set up _go32_info_block structure */ + movzwl STUBINFO_MINKEEP, %eax + movl %eax, U_SYSTEM_GO32_INFO_BLOCK+16 /* .size_of_transfer_buffer */ + .byte 0x64 /* fs: */ + movzwl STUBINFO_DS_SEGMENT, %eax + shll $4, %eax + movl %eax, U_SYSTEM_GO32_INFO_BLOCK+12 /* .linear_address_of_transfer_buffer */ + xorl %eax, %eax + movl $1, %ecx + int $0x31 + jc no_selector + movw %ax, U_SYSTEM_GO32_INFO_BLOCK+26 /* .selector_for_linear_memory */ + movl %eax, %ebx + movl $8, %eax + movl $0x0f, %ecx + movw $0xffff, %dx + int $0x31 /* Set limit 1Mb */ no_selector: .endif - call ___prt1_startup /* run program */ - jmp exit + call ___prt1_startup /* run program */ + jmp exit no_memory: - movb $0xff, %al - jmp exit + movb $0xff, %al + jmp exit /*-----------------------------------------------------------------------------*/ @@ -342,405 +342,405 @@ no_memory: int $0x31 .endm - .global ___exit - .align 2 + .global ___exit + .align 2 ___exit: - movb 4(%esp), %al + movb 4(%esp), %al exit: - movb %al, %cl - xorl %eax,%eax - movw %ax,%fs - movw %ax,%gs + movb %al, %cl + xorl %eax,%eax + movw %ax,%fs + movw %ax,%gs cmpl $0,_exception_exit jz no_exception pushl %ecx call *_exception_exit popl %ecx no_exception: - cli /* Just in case they didn't unhook ints */ - FREESEL U_SYSTEM_GO32_INFO_BLOCK+26 /* selector for linear memory */ - FREESEL ___v2prt0_ds_alias /* DS alias for rmcb exceptions */ + cli /* Just in case they didn't unhook ints */ + FREESEL U_SYSTEM_GO32_INFO_BLOCK+26 /* selector for linear memory */ + FREESEL ___v2prt0_ds_alias /* DS alias for rmcb exceptions */ .ifdef MULTIBLOCK - testb $0x8, __crt0_startup_flags+1 /* include/crt0.h */ - jz 9f + testb $0x8, __crt0_startup_flags+1 /* include/crt0.h */ + jz 9f .endif - FREESEL sbrk16_api_seg /* sbrk cs */ - movw sbrk16_first_byte+6,%dx /* selector for allocated DOS mem */ - movw $0x101, %ax - int $0x31 /* Free block and selector */ + FREESEL sbrk16_api_seg /* sbrk cs */ + movw sbrk16_first_byte+6,%dx /* selector for allocated DOS mem */ + movw $0x101, %ax + int $0x31 /* Free block and selector */ 9: - movl __stubinfo, %edx - movl STUBINFO_CS_SELECTOR(%edx), %eax - movw %ax, sbrk16_api_seg - xorl %edi, %edi - movl %edi, sbrk16_api_ofs /* Offset is zero */ + movl __stubinfo, %edx + movl STUBINFO_CS_SELECTOR(%edx), %eax + movw %ax, sbrk16_api_seg + xorl %edi, %edi + movl %edi, sbrk16_api_ofs /* Offset is zero */ - movw STUBINFO_DS_SELECTOR(%edx), %es - movb %cl, %dl /* Exit status */ - movl $exit16_first_byte, %esi - movl $(exit16_last_byte - exit16_first_byte), %ecx - cld - rep - movsb + movw STUBINFO_DS_SELECTOR(%edx), %es + movb %cl, %dl /* Exit status */ + movl $exit16_first_byte, %esi + movl $(exit16_last_byte - exit16_first_byte), %ecx + cld + rep + movsb - movw %es,%ax /* We will free stack! */ - movw %ax,%ss - movl $0x400,%esp /* Transfer buffer >= 1024 bytes */ + movw %es,%ax /* We will free stack! */ + movw %ax,%ss + movl $0x400,%esp /* Transfer buffer >= 1024 bytes */ .ifdef MULTIBLOCK - movl ___djgpp_memory_handle_pointer, %ebx - jmp 7f -6: subl $8, %ebx - movl (%ebx), %edi - movw 2(%ebx), %si - movw $0x502, %ax - int $0x31 -7: cmpl $___djgpp_memory_handle_list+8, %ebx - jne 6b + movl ___djgpp_memory_handle_pointer, %ebx + jmp 7f +6: subl $8, %ebx + movl (%ebx), %edi + movw 2(%ebx), %si + movw $0x502, %ax + int $0x31 +7: cmpl $___djgpp_memory_handle_list+8, %ebx + jne 6b .endif /* MULTIBLOCK */ - xorl %ebp, %ebp /* V1.10 bug fix */ - movl ___djgpp_memory_handle_list, %edi - movl ___djgpp_memory_handle_list+2, %esi /* Skip word prefixes */ + xorl %ebp, %ebp /* V1.10 bug fix */ + movl ___djgpp_memory_handle_list, %edi + movl ___djgpp_memory_handle_list+2, %esi /* Skip word prefixes */ - FREESEL %ds - movw %cs, %bx + FREESEL %ds + movw %cs, %bx /* Call exit procedure with BX=32-bit CS; SI+DI=32-bit handle; DL=exit status */ - .byte 0x2e - ljmp sbrk16_api_ofs + .byte 0x2e + ljmp sbrk16_api_ofs /*-----------------------------------------------------------------------------*/ -/* .lcomm __what_size_app_thinks_it_is, 4 */ +/* .lcomm __what_size_app_thinks_it_is, 4 */ __what_size_app_thinks_it_is: - .long end - .lcomm __what_we_return_to_app_as_old_size, 4 - .lcomm __what_size_dpmi_thinks_we_are, 4 + .long end + .lcomm __what_we_return_to_app_as_old_size, 4 + .lcomm __what_size_dpmi_thinks_we_are, 4 lock_memory: - /* BX:CX should be linear address; size is pushed on stack */ - testb $0x10, __crt0_startup_flags+1 /* include/crt0.h */ - jz 13f - pushl %esi - pushl %edi - pushl %eax - movl 16(%esp),%edi - movw 18(%esp),%si - movw $0x600,%ax - int $0x31 - popl %eax - popl %edi - popl %esi -13: ret $4 /* Pop the argument */ + /* BX:CX should be linear address; size is pushed on stack */ + testb $0x10, __crt0_startup_flags+1 /* include/crt0.h */ + jz 13f + pushl %esi + pushl %edi + pushl %eax + movl 16(%esp),%edi + movw 18(%esp),%si + movw $0x600,%ax + int $0x31 + popl %eax + popl %edi + popl %esi +13: ret $4 /* Pop the argument */ .if 0 brk_hook_ret: - ret - .globl ___sbrk_brk_hook + ret + .globl ___sbrk_brk_hook ___sbrk_brk_hook: - .long brk_hook_ret + .long brk_hook_ret .endif - .global ___sbrk - .align 2 + .global ___sbrk + .align 2 ___sbrk: - movl __what_size_app_thinks_it_is, %eax - movl 4(%esp), %ecx /* Increment size */ - addl %ecx, %eax - jnc brk_common - /* Carry is only set if a negative increment or wrap happens. Negative - increment is semi-OK, wrap (only for multiple zone sbrk) isn't. */ - test $0x80000000, %ecx /* Clears carry */ - jnz brk_common - stc /* Put carry back */ - jmp brk_common + movl __what_size_app_thinks_it_is, %eax + movl 4(%esp), %ecx /* Increment size */ + addl %ecx, %eax + jnc brk_common + /* Carry is only set if a negative increment or wrap happens. Negative + increment is semi-OK, wrap (only for multiple zone sbrk) isn't. */ + test $0x80000000, %ecx /* Clears carry */ + jnz brk_common + stc /* Put carry back */ + jmp brk_common - .globl ___brk - .align 2 + .globl ___brk + .align 2 ___brk: - movl 4(%esp), %eax - clc + movl 4(%esp), %eax + clc brk_common: - pushl %esi - pushl %edi - pushl %ebx + pushl %esi + pushl %edi + pushl %ebx - movl __what_size_app_thinks_it_is, %edx /* save info */ - movl %edx, __what_we_return_to_app_as_old_size - movl %eax, __what_size_app_thinks_it_is + movl __what_size_app_thinks_it_is, %edx /* save info */ + movl %edx, __what_we_return_to_app_as_old_size + movl %eax, __what_size_app_thinks_it_is - jc 10f /* Wrap for multi-zone */ - cmpl __what_size_dpmi_thinks_we_are, %eax /* don't bother shrinking */ - jbe brk_nochange + jc 10f /* Wrap for multi-zone */ + cmpl __what_size_dpmi_thinks_we_are, %eax /* don't bother shrinking */ + jbe brk_nochange .ifdef MULTIBLOCK - testb $0x8, __crt0_startup_flags+1 /* include/crt0.h */ - jz 10f + testb $0x8, __crt0_startup_flags+1 /* include/crt0.h */ + jz 10f .endif - addl $0x0000ffff, %eax /* round up to 64K block */ - andl $0xffff0000, %eax - push %eax /* size - save for later */ + addl $0x0000ffff, %eax /* round up to 64K block */ + andl $0xffff0000, %eax + push %eax /* size - save for later */ - movl ___djgpp_memory_handle_list, %edi /* request new size */ - movw ___djgpp_memory_handle_list+2, %si - movl %eax, %ecx /* size not limit */ - movl %eax, %ebx /* size not limit */ - shrl $16, %ebx /* BX:CX size */ + movl ___djgpp_memory_handle_list, %edi /* request new size */ + movw ___djgpp_memory_handle_list+2, %si + movl %eax, %ecx /* size not limit */ + movl %eax, %ebx /* size not limit */ + shrl $16, %ebx /* BX:CX size */ - movw $0x0900, %ax /* disable interrupts */ - int $0x31 - pushl %eax + movw $0x0900, %ax /* disable interrupts */ + int $0x31 + pushl %eax - lcall sbrk16_api_ofs - setc %dl /* Save carry */ + lcall sbrk16_api_ofs + setc %dl /* Save carry */ - popl %eax /* restore interrupts */ - int $0x31 + popl %eax /* restore interrupts */ + int $0x31 - test %dl,%dl - popl %edx - jne brk_error + test %dl,%dl + popl %edx + jne brk_error - movl %edi, ___djgpp_memory_handle_list /* store new handle */ - movw %si, ___djgpp_memory_handle_list+2 - movl %ecx, ___djgpp_base_address /* store new base address */ - movw %bx, ___djgpp_base_address+2 + movl %edi, ___djgpp_memory_handle_list /* store new handle */ + movw %si, ___djgpp_memory_handle_list+2 + movl %ecx, ___djgpp_base_address /* store new base address */ + movw %bx, ___djgpp_base_address+2 - movl %edx, %eax - movl __what_size_dpmi_thinks_we_are, %ecx - subl %ecx, %eax + movl %edx, %eax + movl __what_size_dpmi_thinks_we_are, %ecx + subl %ecx, %eax - addl ___djgpp_base_address, %ecx - movl %ecx, %ebx - shrl $16, %ebx /* BX:CX addr */ - pushl %eax /* Size */ - call lock_memory + addl ___djgpp_base_address, %ecx + movl %ecx, %ebx + shrl $16, %ebx /* BX:CX addr */ + pushl %eax /* Size */ + call lock_memory - decl %edx /* limit now, not size */ + decl %edx /* limit now, not size */ .ifdef MULTIBLOCK - jmp 5f + jmp 5f /* Current allocation not large enough, get another block */ -10: movl %ecx, %eax /* Add amt */ - pushl %eax /* Save orig */ - addl $0x0000ffff, %eax /* round up to 64K block */ - andl $0xffff0000, %eax - movl %eax, %edx /* Save size */ - movl %eax, %ecx - movl %eax, %ebx - shrl $16, %ebx /* BX:CX size */ - movw $0x501,%ax - int $0x31 - popl %eax /* Orig size */ - jc brk_error +10: movl %ecx, %eax /* Add amt */ + pushl %eax /* Save orig */ + addl $0x0000ffff, %eax /* round up to 64K block */ + andl $0xffff0000, %eax + movl %eax, %edx /* Save size */ + movl %eax, %ecx + movl %eax, %ebx + shrl $16, %ebx /* BX:CX size */ + movw $0x501,%ax + int $0x31 + popl %eax /* Orig size */ + jc brk_error - pushl %edx /* Size */ - call lock_memory + pushl %edx /* Size */ + call lock_memory - pushw %bx - pushw %cx - popl %ecx /* Linear address */ + pushw %bx + pushw %cx + popl %ecx /* Linear address */ /* What if the new base address is lower than __djgpp_base_address !!! */ - subl ___djgpp_base_address, %ecx /* New dpmi size */ - cmpl %ecx, __what_size_dpmi_thinks_we_are /* Back to back ? */ - je 4f - movl %ecx, __what_size_dpmi_thinks_we_are - movl %ecx, __what_we_return_to_app_as_old_size + subl ___djgpp_base_address, %ecx /* New dpmi size */ + cmpl %ecx, __what_size_dpmi_thinks_we_are /* Back to back ? */ + je 4f + movl %ecx, __what_size_dpmi_thinks_we_are + movl %ecx, __what_we_return_to_app_as_old_size 4: - movl __what_we_return_to_app_as_old_size, %ebx /* Base for new block */ - addl %ebx, %eax /* Final address */ - movl %eax, __what_size_app_thinks_it_is + movl __what_we_return_to_app_as_old_size, %ebx /* Base for new block */ + addl %ebx, %eax /* Final address */ + movl %eax, __what_size_app_thinks_it_is /* Note - save adjusted memory base and memory handle SI:DI here */ - movl ___djgpp_memory_handle_pointer, %ebx - movl %edi, (%ebx) - movw %si, 2(%ebx) - movl %ecx, 4(%ebx) - addl $8, %ebx - cmpl $___djgpp_memory_handle_list+2040, %ebx /* At end? */ - je 11f - movl %ebx, ___djgpp_memory_handle_pointer /* Only if not at end */ + movl ___djgpp_memory_handle_pointer, %ebx + movl %edi, (%ebx) + movw %si, 2(%ebx) + movl %ecx, 4(%ebx) + addl $8, %ebx + cmpl $___djgpp_memory_handle_list+2040, %ebx /* At end? */ + je 11f + movl %ebx, ___djgpp_memory_handle_pointer /* Only if not at end */ 11: - addl %ecx, %edx /* Final address */ - decl %edx /* Limit to end */ + addl %ecx, %edx /* Final address */ + decl %edx /* Limit to end */ /* If we get a block at a lower address we must skip the limit change */ - cmpl ___djgpp_selector_limit, %edx - jbe 12f + cmpl ___djgpp_selector_limit, %edx + jbe 12f .endif -5: movl %edx, ___djgpp_selector_limit - orw $0x0fff, %dx /* low bits set */ - movw $0x0008, %ax /* reset CS limit */ - movw %cs, %bx - movl %edx, %ecx - shrl $16, %ecx - int $0x31 /* CX:DX is limit */ +5: movl %edx, ___djgpp_selector_limit + orw $0x0fff, %dx /* low bits set */ + movw $0x0008, %ax /* reset CS limit */ + movw %cs, %bx + movl %edx, %ecx + shrl $16, %ecx + int $0x31 /* CX:DX is limit */ - testb $0x80, __crt0_startup_flags /* include/crt0.h */ - jnz 3f - movw $0x0008, %ax /* reset DS limit */ - movw %ds, %bx - int $0x31 + testb $0x80, __crt0_startup_flags /* include/crt0.h */ + jnz 3f + movw $0x0008, %ax /* reset DS limit */ + movw %ds, %bx + int $0x31 - movw $0x0008, %ax /* reset DS alias limit */ - movl ___v2prt0_ds_alias, %ebx - int $0x31 + movw $0x0008, %ax /* reset DS alias limit */ + movl ___v2prt0_ds_alias, %ebx + int $0x31 3: - movw $0x0007, %ax /* reset DS alias base */ - movl ___v2prt0_ds_alias, %ebx - movl ___djgpp_base_address, %edx - movw ___djgpp_base_address+2, %cx - int $0x31 + movw $0x0007, %ax /* reset DS alias base */ + movl ___v2prt0_ds_alias, %ebx + movl ___djgpp_base_address, %edx + movw ___djgpp_base_address+2, %cx + int $0x31 - movl ___djgpp_selector_limit, %edx -12: incl %edx /* Size not limit */ - testb $0x60, __crt0_startup_flags /* include/crt0.h */ - jz no_fill_sbrk_memory - pushl %ds - popl %es + movl ___djgpp_selector_limit, %edx +12: incl %edx /* Size not limit */ + testb $0x60, __crt0_startup_flags /* include/crt0.h */ + jz no_fill_sbrk_memory + pushl %ds + popl %es - movl __what_size_dpmi_thinks_we_are, %edi /* set all newly resized bytes zero */ - movl %edx, %ecx /* Limit */ - subl %edi, %ecx /* Adjust count for base */ - xorl %eax, %eax - testb $0x40, __crt0_startup_flags - jz no_deadbeef - movl $0xdeadbeef, %eax /* something really easy to spot */ + movl __what_size_dpmi_thinks_we_are, %edi /* set all newly resized bytes zero */ + movl %edx, %ecx /* Limit */ + subl %edi, %ecx /* Adjust count for base */ + xorl %eax, %eax + testb $0x40, __crt0_startup_flags + jz no_deadbeef + movl $0xdeadbeef, %eax /* something really easy to spot */ no_deadbeef: - shrl $2, %ecx /* div 4 Longwords not bytes */ - cld - rep - stosl + shrl $2, %ecx /* div 4 Longwords not bytes */ + cld + rep + stosl no_fill_sbrk_memory: - movl %edx, __what_size_dpmi_thinks_we_are + movl %edx, __what_size_dpmi_thinks_we_are -.if 0 /* No purpose */ - pushl ___djgpp_memory_handle_list - pushl ___djgpp_base_address - movl ___sbrk_brk_hook, %eax - call %eax - addl $8, %esp +.if 0 /* No purpose */ + pushl ___djgpp_memory_handle_list + pushl ___djgpp_base_address + movl ___sbrk_brk_hook, %eax + call %eax + addl $8, %esp .endif -brk_nochange: /* successful return */ - movl __what_we_return_to_app_as_old_size, %eax - jmp brk_return +brk_nochange: /* successful return */ + movl __what_we_return_to_app_as_old_size, %eax + jmp brk_return -brk_error: /* error return */ - movl __what_we_return_to_app_as_old_size, %eax - movl %eax, __what_size_app_thinks_it_is - movl $-1, %eax +brk_error: /* error return */ + movl __what_we_return_to_app_as_old_size, %eax + movl %eax, __what_size_app_thinks_it_is + movl $-1, %eax brk_return: - popl %ebx - popl %edi - popl %esi - ret + popl %ebx + popl %edi + popl %esi + ret - .globl __crt0_init_mcount + .globl __crt0_init_mcount __crt0_init_mcount: .ifdef IN_GCRT0 - jmp __mcount_init + jmp __mcount_init .else - ret + ret .endif /* From here on this are parts of crt1.c converted to assembler -and without any call to libc, so that it works without anything else +and without any call to libc, so that it works without anything else additions made by Pierre Muller*/ /* from dpmidefs.h * / /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ /* from include */ /* all macros removed here */ -/* #define FUNC(x) .globl x; x: */ +/* #define FUNC(x) .globl x; x: */ -/* #define ENTER pushl %ebp; movl %esp,%ebp */ +/* #define ENTER pushl %ebp; movl %esp,%ebp */ -/* #define LEAVE(x) movl %ebp,%esp; popl %ebp; ret $(x) */ -/* #define ARG1 8(%ebp) -#define ARG1h 10(%ebp) -#define ARG2 12(%ebp) -#define ARG2h 14(%ebp) -#define ARG3 16(%ebp) -#define ARG4 20(%ebp) -#define ARG5 24(%ebp) -#define ARG6 28(%ebp) -#define ARG7 32(%ebp) -#define ARG8 36(%ebp) */ +/* #define LEAVE(x) movl %ebp,%esp; popl %ebp; ret $(x) */ +/* #define ARG1 8(%ebp) +#define ARG1h 10(%ebp) +#define ARG2 12(%ebp) +#define ARG2h 14(%ebp) +#define ARG3 16(%ebp) +#define ARG4 20(%ebp) +#define ARG5 24(%ebp) +#define ARG6 28(%ebp) +#define ARG7 32(%ebp) +#define ARG8 36(%ebp) */ - .comm ___dpmi_error,2 + .comm ___dpmi_error,2 /* from dpmi0000.s */ - .globl ___dpmi_allocate_ldt_descriptors + .globl ___dpmi_allocate_ldt_descriptors ___dpmi_allocate_ldt_descriptors: pushl %ebp; movl %esp,%ebp - movl 8(%ebp), %ecx - movl $0x0000, %eax + movl 8(%ebp), %ecx + movl $0x0000, %eax int $0x31 jnc .L_noerror0000 movw %ax,___dpmi_error movl $-1,%eax jmp .L_leave0000 .L_noerror0000: - movzwl %ax,%eax + movzwl %ax,%eax .L_leave0000: - movl %ebp,%esp - popl %ebp - ret $4 + movl %ebp,%esp + popl %ebp + ret $4 /* from file dpmi0008.s */ - .globl ___dpmi_set_segment_limit + .globl ___dpmi_set_segment_limit ___dpmi_set_segment_limit: pushl %ebp; movl %esp,%ebp - movl 8(%ebp), %ebx - movzwl 12(%ebp), %edx - movzwl 14(%ebp),%ecx + movl 8(%ebp), %ebx + movzwl 12(%ebp), %edx + movzwl 14(%ebp),%ecx - movl $0x0008,%eax + movl $0x0008,%eax int $0x31 jnc .L_noerror0008 movw %ax,___dpmi_error movl $-1,%eax jmp .L_leave0008 .L_noerror0008: - xorl %eax,%eax + xorl %eax,%eax .L_leave0008: - movl %ebp,%esp - popl %ebp - ret $8 + movl %ebp,%esp + popl %ebp + ret $8 - .globl ___dpmi_get_version + .globl ___dpmi_get_version ___dpmi_get_version: pushl %ebp; movl %esp,%ebp - movl $0x0400,%eax + movl $0x0400,%eax int $0x31 jnc .L_noerror0400 movw %ax,___dpmi_error movl $-1,%eax jmp .L_leave0400 .L_noerror0400: - movl 8(%ebp), %esi - movb %ah, (%esi) - movb %al, 1(%esi) - movw %bx, 2(%esi) - movb %cl, 4(%esi) - movb %dh, 5(%esi) - movb %dl, 6(%esi) + movl 8(%ebp), %esi + movb %ah, (%esi) + movb %al, 1(%esi) + movw %bx, 2(%esi) + movb %cl, 4(%esi) + movb %dh, 5(%esi) + movb %dl, 6(%esi) - xorl %eax,%eax + xorl %eax,%eax .L_leave0400: - movl %ebp,%esp - popl %ebp - ret $4 + movl %ebp,%esp + popl %ebp + ret $4 - .globl ___dpmi_get_segment_base_address + .globl ___dpmi_get_segment_base_address ___dpmi_get_segment_base_address: pushl %ebp; movl %esp,%ebp - movl 8(%ebp), %ebx - movl $0x0006,%eax + movl 8(%ebp), %ebx + movl $0x0006,%eax int $0x31 jnc .L_noerror0006 movw %ax,___dpmi_error @@ -748,171 +748,171 @@ ___dpmi_get_segment_base_address: jmp .L_leave0006 .L_noerror0006: - movl 12(%ebp), %ebx - movl %edx, (%ebx) - movw %cx, 2(%ebx) + movl 12(%ebp), %ebx + movl %edx, (%ebx) + movw %cx, 2(%ebx) - xorl %eax,%eax + xorl %eax,%eax .L_leave0006: - movl %ebp,%esp - popl %ebp - ret $8 + movl %ebp,%esp + popl %ebp + ret $8 .globl ___bss_count .data - .align 2 + .align 2 ___bss_count: - .long 1 + .long 1 .text - .align 2 - .globl _setup_core_selector + .align 2 + .globl _setup_core_selector _setup_core_selector: - pushl %ebp - movl %esp,%ebp - pushl $1 - call ___dpmi_allocate_ldt_descriptors - /* addl $4,%esp */ - cmpl $-1,%eax - jne .L24 - movw $0,U_SYSTEM_GO32_INFO_BLOCK+26 - leave - ret - .align 2,0x90 + pushl %ebp + movl %esp,%ebp + pushl $1 + call ___dpmi_allocate_ldt_descriptors + /* addl $4,%esp */ + cmpl $-1,%eax + jne .L24 + movw $0,U_SYSTEM_GO32_INFO_BLOCK+26 + leave + ret + .align 2,0x90 .L24: - movw %ax,U_SYSTEM_GO32_INFO_BLOCK+26 - movw %ax,_core_selector - pushl $0x10ffff - andl $0xffff,%eax - pushl %eax - call ___dpmi_set_segment_limit - leave - ret - .align 2 - .globl _setup_screens + movw %ax,U_SYSTEM_GO32_INFO_BLOCK+26 + movw %ax,_core_selector + pushl $0x10ffff + andl $0xffff,%eax + pushl %eax + call ___dpmi_set_segment_limit + leave + ret + .align 2 + .globl _setup_screens _setup_screens: - pushl %ebp - movl %esp,%ebp - movw U_SYSTEM_GO32_INFO_BLOCK+26,%dx - movl $1048563,%ecx + pushl %ebp + movl %esp,%ebp + movw U_SYSTEM_GO32_INFO_BLOCK+26,%dx + movl $1048563,%ecx /APP - movw %dx, %gs - .byte 0x65 - movw (%ecx),%ax + movw %dx, %gs + .byte 0x65 + movw (%ecx),%ax /NO_APP - cmpw $64896,%ax - jne .L26 - movl $655360,U_SYSTEM_GO32_INFO_BLOCK+8 - movl $655360,U_SYSTEM_GO32_INFO_BLOCK+4 - leave - ret - .align 2,0x90 + cmpw $64896,%ax + jne .L26 + movl $655360,U_SYSTEM_GO32_INFO_BLOCK+8 + movl $655360,U_SYSTEM_GO32_INFO_BLOCK+4 + leave + ret + .align 2,0x90 .L26: - movl $1097,%ecx + movl $1097,%ecx /APP - movw %dx,%gs - .byte 0x65 - movb (%ecx),%al + movw %dx,%gs + .byte 0x65 + movb (%ecx),%al /NO_APP - cmpb $7,%al - jne .L29 - movl $720896,U_SYSTEM_GO32_INFO_BLOCK+4 - movl $753664,U_SYSTEM_GO32_INFO_BLOCK+8 - leave - ret - .align 2,0x90 + cmpb $7,%al + jne .L29 + movl $720896,U_SYSTEM_GO32_INFO_BLOCK+4 + movl $753664,U_SYSTEM_GO32_INFO_BLOCK+8 + leave + ret + .align 2,0x90 .L29: - movl $753664,U_SYSTEM_GO32_INFO_BLOCK+4 - movl $720896,U_SYSTEM_GO32_INFO_BLOCK+8 - leave - ret - .align 2 - .globl _setup_go32_info_block + movl $753664,U_SYSTEM_GO32_INFO_BLOCK+4 + movl $720896,U_SYSTEM_GO32_INFO_BLOCK+8 + leave + ret + .align 2 + .globl _setup_go32_info_block _setup_go32_info_block: - pushl %ebp - movl %esp,%ebp - subl $8,%esp - leal -8(%ebp),%eax - pushl %eax - call ___dpmi_get_version - movl $40,U_SYSTEM_GO32_INFO_BLOCK - movl __stubinfo,%edx - movzwl 36(%edx),%eax - sall $4,%eax - movl %eax,U_SYSTEM_GO32_INFO_BLOCK+12 - movzwl 32(%edx),%ecx - movl %ecx,U_SYSTEM_GO32_INFO_BLOCK+16 - movzwl 38(%edx),%ecx - movl %ecx,U_SYSTEM_GO32_INFO_BLOCK+20 - movb -3(%ebp),%al - movb %al,U_SYSTEM_GO32_INFO_BLOCK+24 - movb -2(%ebp),%al - movb %al,U_SYSTEM_GO32_INFO_BLOCK+25 - movl $-1,U_SYSTEM_GO32_INFO_BLOCK+28 - pushl $U_SYSTEM_GO32_INFO_BLOCK+32 - movzwl 38(%edx),%eax - pushl %eax - call ___dpmi_get_segment_base_address - movw $4,U_SYSTEM_GO32_INFO_BLOCK+36 - movb -8(%ebp),%dl - salw $8,%dx - movzbw -7(%ebp),%ax - orw %ax,%dx - movw %dx,U_SYSTEM_GO32_INFO_BLOCK+38 - leave - ret + pushl %ebp + movl %esp,%ebp + subl $8,%esp + leal -8(%ebp),%eax + pushl %eax + call ___dpmi_get_version + movl $40,U_SYSTEM_GO32_INFO_BLOCK + movl __stubinfo,%edx + movzwl 36(%edx),%eax + sall $4,%eax + movl %eax,U_SYSTEM_GO32_INFO_BLOCK+12 + movzwl 32(%edx),%ecx + movl %ecx,U_SYSTEM_GO32_INFO_BLOCK+16 + movzwl 38(%edx),%ecx + movl %ecx,U_SYSTEM_GO32_INFO_BLOCK+20 + movb -3(%ebp),%al + movb %al,U_SYSTEM_GO32_INFO_BLOCK+24 + movb -2(%ebp),%al + movb %al,U_SYSTEM_GO32_INFO_BLOCK+25 + movl $-1,U_SYSTEM_GO32_INFO_BLOCK+28 + pushl $U_SYSTEM_GO32_INFO_BLOCK+32 + movzwl 38(%edx),%eax + pushl %eax + call ___dpmi_get_segment_base_address + movw $4,U_SYSTEM_GO32_INFO_BLOCK+36 + movb -8(%ebp),%dl + salw $8,%dx + movzbw -7(%ebp),%ax + orw %ax,%dx + movw %dx,U_SYSTEM_GO32_INFO_BLOCK+38 + leave + ret .globl ___PROXY .data ___PROXY: - .ascii " !proxy\0" + .ascii " !proxy\0" .globl ___PROXY_LEN - .align 2 + .align 2 ___PROXY_LEN: - .long 7 + .long 7 .text - .align 2 + .align 2 .globl ___prt1_startup ___prt1_startup: - pushl %ebp - movl %esp,%ebp - pushl %ebx - incl ___bss_count - movl $0,___crt0_argv - call _setup_core_selector - call _setup_screens - call _setup_go32_info_block -/* call ___djgpp_exception_setup - call _setup_environment */ - incl ___environ_changed -/* pushl $0 - call __use_lfn - addl $4,%esp - call ___crt0_setup_arguments - movl ___crt0_argv,%eax - testl %eax,%eax - je .L55 - movl (%eax),%ebx - jmp .L56 - .align 2,0x90 + pushl %ebp + movl %esp,%ebp + pushl %ebx + incl ___bss_count + movl $0,___crt0_argv + call _setup_core_selector + call _setup_screens + call _setup_go32_info_block +/* call ___djgpp_exception_setup + call _setup_ENVPment */ + incl ___environ_changed +/* pushl $0 + call __use_lfn + addl $4,%esp + call ___crt0_setup_arguments + movl ___crt0_argv,%eax + testl %eax,%eax + je .L55 + movl (%eax),%ebx + jmp .L56 + .align 2,0x90 .L55: - movl U_SYSTEM_DOS_ARGV0,%ebx + movl U_SYSTEM_DOS_ARGV0,%ebx .L56: - pushl %ebx - call ___crt0_load_environment_file - pushl $0 - call __use_lfn - pushl %ebx - call __npxsetup - call __crt0_init_mcount - call ___main */ - pushl U_SYSTEM_ENVIRON - pushl ___crt0_argv - pushl ___crt0_argc - call _pascal_start - pushl %eax -/* call _exit changed to */ + pushl %ebx + call ___crt0_load_ENVPment_file + pushl $0 + call __use_lfn + pushl %ebx + call __npxsetup + call __crt0_init_mcount + call ___main */ + pushl U_SYSTEM_ENVP + pushl ___crt0_argv + pushl ___crt0_argc + call _pascal_start + pushl %eax +/* call _exit changed to */ call exit - .align 2,0x90 + .align 2,0x90 /* .comm U_SYSTEM_DOS_ARGV0,4 */ .comm ___crt0_argc,4 .comm ___crt0_argv,4 @@ -932,162 +932,162 @@ _swap_out: _v2prt0_exceptions_on: .long 0 /*.comm __crt0_startup_flags,4 - .comm U_SYSTEM_ENVIRON,4 */ + .comm U_SYSTEM_ENVP,4 */ .ifdef test_go32v1 -#///* -#//** Called as start(argc, argv, envp) -#//*/ -#///* gs:edx points to prog_info structure. All other registers are OBSOLETE -#//** but included for backwards compatibility -#//*/ +# +# Called as start(argc, argv, envp) +# +# gs:edx points to prog_info structure. All other registers are OBSOLETE +# but included for backwards compatibility +# - .text - .globl old_start + .text + .globl old_start old_start: popl %ebx popl %eax - movl %eax,__hard_master - movl %esi,___pid - movl %edi,___transfer_buffer - movl %ebx,_ScreenPrimary - movl %ebp,_ScreenSecondary + movl %eax,__hard_master + movl %esi,___pid + movl %edi,___transfer_buffer + movl %ebx,_ScreenPrimary + movl %ebp,_ScreenSecondary - cmpl $0, %edx - je Lcopy_none - movw %gs,%cx - movw %ds,%ax - cmpw %cx,%ax - je Lcopy_none + cmpl $0, %edx + je Lcopy_none + movw %gs,%cx + movw %ds,%ax + cmpw %cx,%ax + je Lcopy_none - movl %gs:(%edx), %ecx - cmpl U_SYSTEM_GO32_INFO_BLOCK, %ecx - jbe Lcopy_less - movl U_SYSTEM_GO32_INFO_BLOCK, %ecx + movl %gs:(%edx), %ecx + cmpl U_SYSTEM_GO32_INFO_BLOCK, %ecx + jbe Lcopy_less + movl U_SYSTEM_GO32_INFO_BLOCK, %ecx Lcopy_less: - movl $U_SYSTEM_GO32_INFO_BLOCK, %edi - addl $3, %ecx - andl $0xfffffffc, %ecx - movl %ecx, (%edi) - addl $4, %edi - addl $4, %edx - subl $4, %ecx + movl $U_SYSTEM_GO32_INFO_BLOCK, %edi + addl $3, %ecx + andl $0xfffffffc, %ecx + movl %ecx, (%edi) + addl $4, %edi + addl $4, %edx + subl $4, %ecx Lcopy_more: - movl %gs:(%edx), %eax - movl %eax, (%edi) - addl $4, %edx - addl $4, %edi - subl $4, %ecx - jnz Lcopy_more + movl %gs:(%edx), %eax + movl %eax, (%edi) + addl $4, %edx + addl $4, %edi + subl $4, %ecx + jnz Lcopy_more - movl U_SYSTEM_GO32_INFO_BLOCK+4, %eax - movl %eax, _ScreenPrimary - movl U_SYSTEM_GO32_INFO_BLOCK+8, %eax - movl %eax, _ScreenSecondary - movl U_SYSTEM_GO32_INFO_BLOCK+12, %eax - movl %eax, ___transfer_buffer - movl U_SYSTEM_GO32_INFO_BLOCK+20, %eax - movl %eax, ___pid - movl U_SYSTEM_GO32_INFO_BLOCK+24, %eax - movl %eax, __hard_master + movl U_SYSTEM_GO32_INFO_BLOCK+4, %eax + movl %eax, _ScreenPrimary + movl U_SYSTEM_GO32_INFO_BLOCK+8, %eax + movl %eax, _ScreenSecondary + movl U_SYSTEM_GO32_INFO_BLOCK+12, %eax + movl %eax, ___transfer_buffer + movl U_SYSTEM_GO32_INFO_BLOCK+20, %eax + movl %eax, ___pid + movl U_SYSTEM_GO32_INFO_BLOCK+24, %eax + movl %eax, __hard_master - jmp Lcopy_done + jmp Lcopy_done Lcopy_none: - movl %ebx,U_SYSTEM_GO32_INFO_BLOCK+4 - movl %ebp,U_SYSTEM_GO32_INFO_BLOCK+8 - movl %edi,U_SYSTEM_GO32_INFO_BLOCK+12 - movl $4096,U_SYSTEM_GO32_INFO_BLOCK+16 - movl %esi,U_SYSTEM_GO32_INFO_BLOCK+20 - movl %eax,U_SYSTEM_GO32_INFO_BLOCK+24 - movl $28, U_SYSTEM_GO32_INFO_BLOCK + movl %ebx,U_SYSTEM_GO32_INFO_BLOCK+4 + movl %ebp,U_SYSTEM_GO32_INFO_BLOCK+8 + movl %edi,U_SYSTEM_GO32_INFO_BLOCK+12 + movl $4096,U_SYSTEM_GO32_INFO_BLOCK+16 + movl %esi,U_SYSTEM_GO32_INFO_BLOCK+20 + movl %eax,U_SYSTEM_GO32_INFO_BLOCK+24 + movl $28, U_SYSTEM_GO32_INFO_BLOCK Lcopy_done: movw U_SYSTEM_GO32_INFO_BLOCK+36,%ax movw %ax,_run_mode - cmpw $4,%ax - jne CanOnlyRunDPMI - call Correct_tbaddress + cmpw $4,%ax + jne CanOnlyRunDPMI + call Correct_tbaddress LtbaddressOK: movw U_SYSTEM_GO32_INFO_BLOCK+26,%ax movw %ax,_core_selector /* core selector in %fs */ movw %ax,%fs - xorl %esi,%esi - xorl %edi,%edi - xorl %ebp,%ebp - xorl %ebx,%ebx + xorl %esi,%esi + xorl %edi,%edi + xorl %ebp,%ebp + xorl %ebx,%ebx - movl %esp,%ebx + movl %esp,%ebx movl $0x0,%ebp - movl %esp,%ebx - movl 8(%ebx),%eax - movl %eax,U_SYSTEM_ENVIRON - movl 4(%ebx),%eax - movl %eax,_args - movl (%ebx),%eax - movl %eax,_argc + movl %esp,%ebx + movl 8(%ebx),%eax + movl %eax,U_SYSTEM_ENVP + movl 4(%ebx),%eax + movl %eax,_args + movl (%ebx),%eax + movl %eax,_argc - call PASCALMAIN + call PASCALMAIN exit_again: - movl $0x4c00,%eax - int $0x21 - jmp exit_again + movl $0x4c00,%eax + int $0x21 + jmp exit_again - ret + ret Correct_tbaddress: - movl ___transfer_buffer,%eax - addl $1,%eax - andl $0xFFFFF,%eax - movl %eax,___transfer_buffer - movl %eax,U_SYSTEM_GO32_INFO_BLOCK+12 - ret + movl ___transfer_buffer,%eax + addl $1,%eax + andl $0xFFFFF,%eax + movl %eax,___transfer_buffer + movl %eax,U_SYSTEM_GO32_INFO_BLOCK+12 + ret CanOnlyRunDPMI: - movl $0x4c01,%eax - int $0x21 + movl $0x4c01,%eax + int $0x21 jmp exit_again .ascii "Can only run in DPMI " -/* .data +/* .data .globl _argc _argc: - .long 0 - .globl _args + .long 0 + .globl _args _args: - .long 0 - .globl _run_mode + .long 0 + .globl _run_mode _run_mode: - .word 0 - .globl _core_selector + .word 0 + .globl _core_selector _core_selector: - .word 0 - .globl _environ -_environ: - .long 0 */ + .word 0 + .globl _ENVP +_ENVP: + .long 0 */ - .globl ___pid + .globl ___pid ___pid: - .long 42 + .long 42 - .globl ___transfer_buffer + .globl ___transfer_buffer ___transfer_buffer: - .long 0 + .long 0 - .globl _ScreenSecondary + .globl _ScreenSecondary _ScreenSecondary: - .long 0 + .long 0 - .globl __hard_master - .globl __hard_slave - .globl __core_select + .globl __hard_master + .globl __hard_slave + .globl __core_select __hard_master: - .byte 0 + .byte 0 __hard_slave: - .byte 0 + .byte 0 .endif /* test_go32v1 */ @@ -1095,51 +1095,51 @@ __hard_slave: // // call as start(argc, argv, envp) (C-calling convention) // - .globl _pascal_start + .globl _pascal_start _pascal_start: /* %ebx doesn't contain ScreenPrimary */ - movl U_SYSTEM_GO32_INFO_BLOCK+4,%ebx - movl %ebx,_ScreenPrimary + movl U_SYSTEM_GO32_INFO_BLOCK+4,%ebx + movl %ebx,_ScreenPrimary /* core selector in %fs */ movw _core_selector,%ax movw %ax,%fs // Top of frame movl $0x0,%ebp - movl %esp,%ebx - movl 12(%ebx),%eax - movl %eax,U_SYSTEM_ENVIRON - movl 8(%ebx),%eax - movl %eax,_args - movl 4(%ebx),%eax - movl %eax,_argc + movl %esp,%ebx + movl 12(%ebx),%eax + movl %eax,U_SYSTEM_ENVP + movl 8(%ebx),%eax + movl %eax,_args + movl 4(%ebx),%eax + movl %eax,_argc - call PASCALMAIN + call PASCALMAIN movl $0,%eax /* no error if passing here */ -/* movl $0x4c00,%eax - int $0x21 */ +/* movl $0x4c00,%eax + int $0x21 */ - ret + ret - .data + .data -/* .comm U_SYSTEM_ENVIRON,4 */ - .globl _ScreenPrimary +/* .comm U_SYSTEM_ENVP,4 */ + .globl _ScreenPrimary _ScreenPrimary: - .long 0 - .globl _argc + .long 0 + .globl _argc _argc: - .long 0 - .globl _args + .long 0 + .globl _args _args: - .long 0 - .globl _run_mode + .long 0 + .globl _run_mode _run_mode: - .word 4 - .globl _core_selector + .word 4 + .globl _core_selector _core_selector: - .word 0 + .word 0 /* Here Pierre Muller added all what was in crt1.c */ /* in assembler */ @@ -1161,36 +1161,20 @@ _core_selector: ___bs_count: .long 1 - .globl __crt0_startup_flags + .globl __crt0_startup_flags __crt0_startup_flags: - .long 0 + .long 0 - .globl __dos_ds + .globl __dos_ds __dos_ds: - .long 0 + .long 0 /* $Log$ - Revision 1.1 1998-03-25 11:18:42 root - Initial revision - - Revision 1.7 1998/03/19 10:04:30 pierre - + changed as files so that they can be compiled by GNU as directly - changed the makefile accordingly - - Revision 1.6 1998/02/03 15:52:46 pierre - * swapvectors really disable exception handling - and interrupt redirection with go32v2 - * in dos.pp bug if arg path from fsearch had a directory part fixed - - Revision 1.5 1998/02/01 14:04:27 peter - * Fixed exit status which was wrong when exception_exit was used - - Revision 1.4 1998/01/19 17:03:51 pierre - * %fs was set in a commented part, corrected - - Revision 1.3 1998/01/16 16:46:53 pierre - + %fs contains the core selector at startup + Revision 1.2 1998-05-22 00:39:38 peter + * go32v1, go32v2 recompiles with the new objects + * remake3 works again with go32v2 + - removed some "optimizes" from daniel which were wrong */ diff --git a/rtl/dos/graph.pp b/rtl/dos/graph.pp index 5bb409cb84..770a1f7202 100644 --- a/rtl/dos/graph.pp +++ b/rtl/dos/graph.pp @@ -1,9 +1,11 @@ { $Id$ This file is part of the Free Pascal run time library. - Copyright (c) 1993,97 by Florian klaempf & Gernot Tenchio + Copyright (c) 1993-98 by Florian Klaempf & Gernot Tenchio members of the Free Pascal development team. + Graph unit for BP7 compatible RTL + See the file COPYING.FPC, included in this distribution, for details about the copyright. @@ -824,44 +826,9 @@ end. { $Log$ - Revision 1.2 1998-03-26 10:41:15 florian - * some warnings fixed + Revision 1.3 1998-05-22 00:39:23 peter + * go32v1, go32v2 recompiles with the new objects + * remake3 works again with go32v2 + - removed some "optimizes" from daniel which were wrong - Revision 1.1.1.1 1998/03/25 11:18:41 root - * Restored version - - Revision 1.7 1998/03/03 22:48:41 florian - + graph.drawpoly procedure - + putimage with xorput uses mmx if available - - Revision 1.6 1998/03/02 00:17:26 carl - +GraphErrorMsg function implemented - - Revision 1.5 1998/02/25 17:08:07 jonas - * change interface definition of SetGraphMode to match the implementation - - Revision 1.4 1998/01/26 11:56:33 michael - + Added log at the end - - - - Working file: rtl/dos/graph.pp - description: - ---------------------------- - revision 1.3 - date: 1997/12/03 15:24:19; author: florian; state: Exp; lines: +38 -11 - Graph.SetGraphMode for DOS added - ---------------------------- - revision 1.2 - date: 1997/12/01 12:15:46; author: michael; state: Exp; lines: +15 -73 - + added copyright reference in header. - ---------------------------- - revision 1.1 - date: 1997/11/27 08:33:50; author: michael; state: Exp; - Initial revision - ---------------------------- - revision 1.1.1.1 - date: 1997/11/27 08:33:50; author: michael; state: Exp; lines: +0 -0 - FPC RTL CVS start - ============================================================================= } diff --git a/rtl/dos/mouse.pp b/rtl/dos/mouse.pp index 13d6296e34..be5c98a1a5 100644 --- a/rtl/dos/mouse.pp +++ b/rtl/dos/mouse.pp @@ -3,6 +3,8 @@ This file is part of the Free Pascal run time library. Copyright (c) 1993,97 by the Free Pascal development team + Mouse unit containing allmost all interrupt 33h functions + See the file COPYING.FPC, included in this distribution, for details about the copyright. @@ -405,31 +407,9 @@ Begin End. { $Log$ - Revision 1.3 1998-04-05 13:56:54 peter - - fixed mouse to compile with $i386_att - + linux crt supports redirecting (not Esc-codes anymore) + Revision 1.4 1998-05-22 00:39:25 peter + * go32v1, go32v2 recompiles with the new objects + * remake3 works again with go32v2 + - removed some "optimizes" from daniel which were wrong - Revision 1.2 1998/03/26 12:25:22 peter - * integrated both mouse units - - Revision 1.1.1.1 1998/03/25 11:18:41 root - * Restored version - - Revision 1.4 1998/03/24 15:53:12 peter - * cleanup and doesn't give warnings when compiling - - Revision 1.3 1998/01/26 11:56:24 michael - + Added log at the end - - Revision 1.2 - date: 1997/12/01 12:15:45; author: michael; state: Exp; lines: +14 -12 - + added copyright reference in header. - - Revision 1.1 - date: 1997/11/27 08:33:49; author: michael; state: Exp; - Initial revision - - Revision 1.1.1.1 - date: 1997/11/27 08:33:49; author: michael; state: Exp; lines: +0 -0 - FPC RTL CVS start } diff --git a/rtl/dos/printer.pp b/rtl/dos/printer.pp index df35b5d924..a0d33f11e3 100644 --- a/rtl/dos/printer.pp +++ b/rtl/dos/printer.pp @@ -1,9 +1,11 @@ { $Id$ This file is part of the Free Pascal run time library. - Copyright (c) 1993,97 by Florian Klaempfl + Copyright (c) 1993,98 by Florian Klaempfl member of the Free Pascal development team + Printer unit for BP7 compatible RTL + See the file COPYING.FPC, included in this distribution, for details about the copyright. @@ -12,62 +14,35 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. **********************************************************************} - -{ - History: - 10.4.1994: Version 1.0 - Unit is completely implemented -} - unit printer; - - interface +interface - var - lst : text; +var + lst : text; - implementation +implementation - var - old_exit : pointer; +var + old_exit : pointer; - procedure printer_exit; - - begin - close(lst); - exitproc:=old_exit; - end; - +procedure printer_exit; begin - assign(lst,'PRN'); - rewrite(lst); - old_exit:=exitproc; - exitproc:=@printer_exit; -end. + close(lst); + exitproc:=old_exit; +end; + +begin + assign(lst,'PRN'); + rewrite(lst); + old_exit:=exitproc; + exitproc:=@printer_exit; +end. { $Log$ - Revision 1.1 1998-03-25 11:18:41 root - Initial revision + Revision 1.2 1998-05-22 00:39:26 peter + * go32v1, go32v2 recompiles with the new objects + * remake3 works again with go32v2 + - removed some "optimizes" from daniel which were wrong - Revision 1.3 1998/01/26 11:56:59 michael - + Added log at the end - - - - Working file: rtl/dos/printer.pp - description: - ---------------------------- - revision 1.2 - date: 1997/12/01 12:15:48; author: michael; state: Exp; lines: +13 -6 - + added copyright reference in header. - ---------------------------- - revision 1.1 - date: 1997/11/27 08:33:50; author: michael; state: Exp; - Initial revision - ---------------------------- - revision 1.1.1.1 - date: 1997/11/27 08:33:50; author: michael; state: Exp; lines: +0 -0 - FPC RTL CVS start - ============================================================================= }