diff --git a/compiler/i386/ag386int.pas b/compiler/i386/ag386int.pas index 6803bfce98..e11227fb63 100644 --- a/compiler/i386/ag386int.pas +++ b/compiler/i386/ag386int.pas @@ -169,21 +169,6 @@ implementation AsmWrite(symbol.name); first:=false; end; - if (aktoutputformat = as_i386_wasm) then - begin - if offset<0 then - begin - AsmWrite(tostr(offset)); - first:=false; - end - else if (offset>0) then - begin - if not first then - AsmWrite('+'); - AsmWrite(tostr(offset)); - first:=false; - end; - end; if (base<>NR_NO) then begin if not(first) then @@ -202,8 +187,6 @@ implementation if scalefactor<>0 then AsmWrite('*'+tostr(scalefactor)); end; - if (aktoutputformat <> as_i386_wasm) then - begin if offset<0 then begin AsmWrite(tostr(offset)); @@ -214,7 +197,6 @@ implementation AsmWrite('+'+tostr(offset)); first:=false; end; - end; if first then AsmWrite('0'); AsmWrite(']'); @@ -617,7 +599,6 @@ implementation word prefix to get selectors to be pushed in 2 bytes PM } if (taicpu(hp).opsize=S_W) and - ( ( ( (taicpu(hp).opcode=A_PUSH) or @@ -625,12 +606,7 @@ implementation ) and (taicpu(hp).oper[0].typ=top_reg) and is_segment_reg(taicpu(hp).oper[0].reg) - ) or - ( - (taicpu(hp).opcode=A_PUSH) and - (taicpu(hp).oper[0].typ=top_const) - ) - ) then + ) then AsmWriteln(#9#9'DB'#9'066h'); { added prefix instructions, must be on same line as opcode } @@ -661,7 +637,16 @@ implementation end else prefix:= ''; - AsmWrite(#9#9+prefix+std_op2str[taicpu(hp).opcode]+cond2str[taicpu(hp).condition]+suffix); + if (aktoutputformat = as_i386_wasm) and + (taicpu(hp).opsize=S_W) and + (taicpu(hp).opcode=A_PUSH) and + (taicpu(hp).oper[0].typ=top_const) then + begin + AsmWriteln(#9#9'DB 66h,68h ; pushw imm16'); + AsmWrite(#9#9'DW'); + end + else + AsmWrite(#9#9+prefix+std_op2str[taicpu(hp).opcode]+cond2str[taicpu(hp).condition]+suffix); if taicpu(hp).ops<>0 then begin if is_calljmp(taicpu(hp).opcode) then @@ -890,7 +875,10 @@ initialization end. { $Log$ - Revision 1.39 2003-09-23 17:56:06 peter + Revision 1.40 2003-09-30 08:39:50 michael + + Patch from Wiktor Sywula for watcom support + + Revision 1.39 2003/09/23 17:56:06 peter * locals and paras are allocated in the code generation * tvarsym.localloc contains the location of para/local when generating code for the current procedure diff --git a/compiler/pmodules.pas b/compiler/pmodules.pas index 8f1072a1db..66fd8fbcb7 100644 --- a/compiler/pmodules.pas +++ b/compiler/pmodules.pas @@ -359,6 +359,8 @@ implementation ; system_powerpc_macos: ; + system_i386_watcom: + ; system_alpha_linux: ; system_m68k_Mac: @@ -1441,7 +1443,10 @@ implementation end. { $Log$ - Revision 1.126 2003-09-23 18:03:08 peter + Revision 1.127 2003-09-30 08:39:50 michael + + Patch from Wiktor Sywula for watcom support + + Revision 1.126 2003/09/23 18:03:08 peter * add missing release of main_proc Revision 1.125 2003/09/23 17:56:05 peter diff --git a/compiler/systems/i_watcom.pas b/compiler/systems/i_watcom.pas index 2dff2d9209..8bf257df03 100644 --- a/compiler/systems/i_watcom.pas +++ b/compiler/systems/i_watcom.pas @@ -2,7 +2,7 @@ $Id$ Copyright (c) 1998-2002 by Peter Vreman - This unit implements support information structures for go32v2 + This unit implements support information structures for Watcom This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,7 +19,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. **************************************************************************** } -{ This unit implements support information structures for go32v2. } +{ This unit implements support information structures for Watcom. } unit i_watcom; {$i fpcdefs.inc} @@ -63,7 +63,7 @@ unit i_watcom; newline : #13#10; dirsep : '\'; files_case_relevent : false; - assem : as_i386_coff; + assem : as_i386_wasm; assemextern : as_gas; link : nil; linkextern : nil; @@ -105,6 +105,9 @@ initialization end. { $Log$ - Revision 1.1 2003-09-06 10:01:11 florian + Revision 1.2 2003-09-30 08:39:50 michael + + Patch from Wiktor Sywula for watcom support + + Revision 1.1 2003/09/06 10:01:11 florian + added *_watcom units } diff --git a/compiler/systems/t_watcom.pas b/compiler/systems/t_watcom.pas index 44305daea5..2486935b88 100644 --- a/compiler/systems/t_watcom.pas +++ b/compiler/systems/t_watcom.pas @@ -25,30 +25,29 @@ unit t_watcom; {$i fpcdefs.inc} - interface +interface + + +implementation + + uses + link, + cclasses,cutils,strings,globtype,globals, + systems,verbose,script,fmodule,i_watcom; - uses - link; type - plinkerwatcom=^tlinkerwatcom; tlinkerwatcom=class(texternallinker) private Function WriteResponseFile(isdll:boolean) : Boolean; public - constructor create;override; - procedure SetDefaultInfo;virtual; - function MakeExecutable:boolean;virtual; -{ function MakeSharedLibrary:boolean;virtual;} + constructor Create;override; + procedure SetDefaultInfo;override; + function MakeExecutable:boolean;override; +{ function MakeSharedLibrary:boolean;override;} end; - implementation - - uses - cclasses,cutils,strings,globtype,globals,systems,verbose,script,fmodule,i_watcom; - - {**************************************************************************** TLinkerWatcom ****************************************************************************} @@ -64,7 +63,7 @@ end; procedure TLinkerWatcom.SetDefaultInfo; begin with Info do - ExeCmd[1]:='wlink system causeway option quiet $OPT $STRIP name $EXE @$RES'; + ExeCmd[1]:='wlink system causeway option quiet option nocaseexact $OPT $STRIP name $EXE @$RES'; end; Function TLinkerWatcom.WriteResponseFile(isdll:boolean) : Boolean; @@ -79,12 +78,21 @@ begin { Open link.res file } LinkRes:=TLinkRes.Create(outputexedir+Info.ResName); + { Write object files, start with prt0 } + LinkRes.Add('file '+GetShortName(FindObjectFile('prt0','',false))); + if not ObjectFiles.Empty then + While not ObjectFiles.Empty do + begin + S:=ObjectFiles.GetFirst; + LinkRes.AddFileName('file '+GetShortName(s)); + end; + { Write staticlibraries } if not StaticLibFiles.Empty then While not StaticLibFiles.Empty do begin S:=StaticLibFiles.GetFirst; - LinkRes.AddFileName('file '+GetShortName(s)) + LinkRes.AddFileName('file '+GetShortName(s)); end; (* @@ -143,12 +151,9 @@ begin { Call linker } SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr); - if pos(' ',current_module.exefilename^)>0 then - Replace(cmdstr,'$EXE','"'+current_module.exefilename^+'"') - else - Replace(cmdstr,'$EXE',current_module.exefilename^); + Replace(cmdstr,'$EXE',maybequoted(current_module.exefilename^)); Replace(cmdstr,'$OPT',Info.ExtraOptions); - Replace(cmdstr,'$RES',outputexedir+Info.ResName); + Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName)); Replace(cmdstr,'$STRIP',StripStr); success:=DoExec(FindUtil(BinStr),cmdstr,true,false); @@ -164,12 +169,19 @@ begin MakeSharedLibrary:=false; end;} +{***************************************************************************** + Initialize +*****************************************************************************} + initialization RegisterExternalLinker(system_i386_watcom_info,TLinkerWatcom); RegisterTarget(system_i386_watcom_info); end. { $Log$ - Revision 1.1 2003-09-06 10:01:11 florian + Revision 1.2 2003-09-30 08:39:50 michael + + Patch from Wiktor Sywula for watcom support + + Revision 1.1 2003/09/06 10:01:11 florian + added *_watcom units } diff --git a/rtl/watcom/prt0.asm b/rtl/watcom/prt0.asm index 5ffdcd4b13..af433e56c1 100644 --- a/rtl/watcom/prt0.asm +++ b/rtl/watcom/prt0.asm @@ -5,50 +5,57 @@ .387 .386p - name prt0 - assume nothing - extrn PASCALMAIN : near - public start - public ___exit - public ___sbrk + name prt0 + assume nothing + extrn PASCALMAIN : near + extrn HEAPSIZE : dword + public start + public ___exit + public ___sbrk + public HEAP .STACK 1000h .CODE start proc near - jmp short main - db "WATCOM" - main: - push ds - pop es - push ds - pop fs - call PASCALMAIN - mov ah,4Ch - int 21h + jmp short main + db "WATCOM" + main: + push ds + pop es + push ds + pop fs + mov eax,HEAPSIZE + push eax + call ___sbrk + mov HEAP,eax + pop eax + call PASCALMAIN start endp ___exit proc near - pop eax - mov ah,4Ch - int 21h + pop eax + mov ah,4Ch + int 21h ___exit endp ___sbrk proc near - mov ebx,dword ptr [esp+4] ; size - mov cx,bx - shr ebx,16 - mov ax,501h - int 31h - jnc sbrk_ok - sbrk_failed: - xor eax,eax - ret - sbrk_ok: - shl ebx,16 - mov bx,cx - mov eax,ebx - ret + mov ebx,dword ptr [esp+4] + mov ecx,ebx + shr ebx,16 + mov ax,501h + int 31h + jnc sbrk_ok + xor eax,eax + ret + sbrk_ok: + shl ebx,16 + mov bx,cx + mov eax,ebx + ret ___sbrk endp +.DATA + HEAP dd 0 + end start