home *** CD-ROM | disk | FTP | other *** search
/ Delphi Programming Unleashed / Delphi_Programming_Unleashed_SAMS_Publishing_1995.iso / docs / delphdos.txt next >
Text File  |  1995-04-30  |  10KB  |  271 lines

  1. Instructions for preparing DELPHI to compile a DOS EXE with DCC.EXE
  2.  
  3. Requirements:
  4.   1) BP7 Runtime library source
  5.   2) Delphi VCL source
  6.   3) TASM.EXE
  7.   4) The new DLIB.EXE (available from CompuServe DELPHI forum)
  8.  
  9. Assumptions:
  10.   1) BP7 RTL is in \BP\RTL
  11.   2) Delphi VCL is in \DELPHI\SOURCE
  12.   3) \DELPHI\BIN is in your path as well as TASM.EXE
  13.  
  14. Copy from \BP\RTL\SYS to \DELPHI\SOURCE\RTL\SYS (all are .ASM):
  15.   MAIN, PARS, LAST, HEAP, F87H, EI87, EI86, DLIB, DAPP
  16.   (* note ERRC that was in this list has been removed - it should
  17.      not be copied over or exception handling will not work *)
  18.  
  19. -- DOS Real Mode ----------------------------------------------------------
  20.   Objective: create a TURBO.TPL with units compiled under DELPHI
  21.  
  22. 1) The first and main requirement is to get a SYSTEM.TPU for DOS mode.
  23. This will take some work because Delphi VCL source does not include
  24. MAIN.ASM which is required for compiling SYSTEM.PAS in DOS mode.  
  25. Some things need to be removed from MAIN.ASM because they now exist 
  26. in EXIT.ASM:
  27.   - remove HaltTurbo, HaltError, Terminate, PrintString from the PUBLIC
  28.     section.
  29.   - remove the procedure code for the above procedures.  (HaltError
  30.     starts in around line 210 or so and HaltTurbo starts around 230
  31.     or so.  PrintString ends around 395 +/- a few.)
  32.   - up at the top in Externals after "ASSUME  CS:CODE,DS:DATA" add 
  33.     another "EXTRN HaltError:NEAR,HaltTurbo:NEAR"
  34.   - down in "Int3FHandler" remove "SHORT" from "JMP SHORT HaltError"
  35.   - after "MOV AX,200" in Int00Handler add "JMP HaltError"
  36.   - after "MOV AX,255" in Int23Handler add "JMP HaltTurbo"
  37.  
  38. 2) Create OBJ from ASM: In \DELPHI\SOURCE\RTL\SYS type 
  39.      TASM *.ASM
  40.  
  41. 3) Compile SYSTEM: In \DELPHI\SOURCE\RTL\SYS type
  42.      DCC -cd -$d- -o\BP\RTL\LIB SYSTEM
  43.      
  44. 4) Start your TURBO.TPL: In \DELPHI\BIN type
  45.      DLIB TURBO.TPL +..\SOURCE\RTL\SYS\SYSTEM.TPU
  46.     
  47. Other files you may want to compile and include in TURBO.TPL:
  48.   unit      source can be found
  49.   OVERLAY   \BP\RTL\OVR
  50.   CRT       \BP\RTL\CRT
  51.   DOS       \BP\RTL\DOS (need to use TASM again)
  52.   PRINTER   \BP\RTL\PRT
  53.   STRINGS   \DELPHI\SOURCE\RTL70    (optional)
  54.   MEMORY    \BP\RTL\TV              (optional)
  55.   OBJECTS   \BP\RTL\COMMON          (optional)
  56. Compile the above files in the specified directory using DCC with the
  57. parameters -cd and -$d- to create "ver 8.0" .TPU files.  Then add the
  58. TPU files to TURBO.TPL as shown in step 4.
  59.  
  60. Now you're all set!  Use DCC with the "undocumented" -cd switch to create
  61. DOS EXEs with classes, exception handling, etc.
  62.  
  63.  
  64. -- DOS Protected Mode -----------------------------------------------------
  65.   Objective: create a TPP.TPL with units compiled under DELPHI
  66.  
  67. 1) Make sure the .OBJ files still exist from step 2 above.
  68.  
  69. 2) Create OBP from ASM: In \DELPHI\SOURCE\RTL\SYS type 
  70.      TASM -op -d_DPMI_ *.ASM *.OBP
  71.  
  72. 3) Compile SYSTEM: In \DELPHI\SOURCE\RTL\SYS type
  73.      DCC -cp -$d- -o\BP\RTL\LIB SYSTEM
  74.      
  75. 4) Start your TURBO.TPL: In \DELPHI\BIN type
  76.      DLIB TPP.TPL +..\SOURCE\RTL\SYS\SYSTEM.TPP
  77.     
  78. Other files you may want to compile and include in TPP.TPL:
  79.   unit      source can be found
  80.   CRT       \BP\RTL\CRT
  81.   DOS       \BP\RTL\DOS (TASM -op -d_DPMI_ *.ASM *.OBP)
  82.   PRINTER   \BP\RTL\PRT
  83.   STRINGS   \DELPHI\SOURCE\RTL70    
  84.   WINDOS    \DELPHI\SOURCE\RTL70
  85.   WINAPI    \DELPHI\SOURCE\RTL\WIN
  86.   MEMORY    \BP\RTL\TV              (optional)
  87.   OBJECTS   \BP\RTL\COMMON          (optional)
  88.   SYSUTILS  \DELPHI\SOURCE\RTL\SYS  (new, see below)
  89. Compile the above files in the specified directory using DCC with the
  90. parameters -cp and -$d- to create "ver 8.0" .TPP files.  Then add the
  91. TPP files to TPP.TPL as shown in step 4.
  92.  
  93.  
  94. -- SysUtils for DOS Protected Mode ----------------------------------------
  95. To get SYSUTILS to work properly in DOS PM you need to make a few minor
  96. changes to the source file (comes with VCL Source).  First make a backup
  97. of the SYSUTILS.PAS file and then I suggest puting "{$IFDEF WINDOWS}..." 
  98. around all of your changes.
  99.  
  100. 1) FileRead/FileWrite: RTM.EXE only supports _lread/write not _hread/write
  101.    and SysUtils needs to be updated to reflect that.  I will use FileRead
  102.    as the example:
  103.    In INTERFACE
  104.      {$IFDEF WINDOWS}
  105.      function FileRead(Handle: Integer; var Buffer; Count: Longint): Longint;
  106.      {$ELSE}
  107.      function FileRead(Handle: Integer; var Buffer; Count: Word): Word;
  108.      {$ENDIF}
  109.    In IMPLEMENTATION
  110.      function FileRead(Handle: Integer; var Buffer; Count: Word): Word;
  111.        external 'KERNEL' index 82; { _lread }
  112.    FileWrite needs the same changes and it has an external index of 86.
  113.    
  114. 2) Units used in the IMPLEMENTATION section:
  115.      {$IFDEF WINDOWS}
  116.      uses WinTypes, WinProcs, ToolHelp;
  117.      {$ELSE}
  118.      uses WinAPI;
  119.      {$ENDIF}
  120.  
  121. 3) Remove some exception (hardware, etc) handling.  Unfortunately RTM
  122.    does not support MakeProcInstance and FreeProcInstance otherwise 
  123.    none of the following would have to be removed.
  124.    A) in the INTERFACE section
  125.       {$IFDEF WINDOWS}
  126.       procedure EnableExceptionHandler(Enable: Boolean);
  127.       {$ENDIF}
  128.       
  129.    B) Around the procedure "GetModNameAndLogAddr" in the IMPLEMENTATION
  130.       section add {$IFDEF WINDOWS} and {$ENDIF}.
  131.       
  132.    C) In the procedure "ShowException":
  133.       var
  134.         .. existing definitions
  135.         Buffer: array[0..255] of Char;
  136.         {$IFDEF WINDOWS}
  137.         GlobalEntry: TGlobalEntry;
  138.         hMod: THandle;
  139.         {$ENDIF}
  140.       begin
  141.         {$IFDEF WINDOWS}
  142.         .. existing code
  143.         {$ENDIF}
  144.       end;
  145.    D) Before the procedure "ErrorHandler":
  146.       {$IFDEF WINDOWS}
  147.       const
  148.         Flags   = $10;
  149.         .. other consts
  150.             
  151.         Recurse: Word = 0;
  152.       {$ENDIF}
  153.    E) In the procedure "ErrorHandler":
  154.         1: E := OutOfMemory;
  155.         {$IFDEF WINDOWS}
  156.         2,4..10: with ExceptMap[ErrorCode] do E := EClass.CreateRes(EIdent);
  157.         3,11..16:
  158.         ..
  159.         end;
  160.         {$ELSE}
  161.         2..16: with ExceptMap[ErrorCode] do E := EClass.CreateRes(EIdent);
  162.         {$ENDIF}
  163.       else
  164.    F) Before the procedure "InterruptCallBack" add {$IFDEF WINDOWS} and
  165.       after the end of the procedure "EnableExceptionHandler" add {$ENDIF}.
  166.    G) In procedure "DoneExceptions" put IFDEF WINDOWS around the call to
  167.       EnableExceptionHandler.
  168.    H) In procedure "InitExceptions" put IFDEF WINDOWS around the assignment
  169.       "TaskID := GetCurrentTask;" and the call to EnableExceptionHandler.
  170.       
  171. 4) Add profile support provided in RTM.EXE.  After the comment 
  172.    "{ Initialization file support }" add the following:
  173.       {$IFNDEF WINDOWS}
  174.       function GetProfileInt( appName, keyName : pchar;
  175.         default : integer ) : word; far; external 'KERNEL' index 57;
  176.       function GetProfileString( appName, keyName, default, returned : pchar;
  177.         size : integer ) : integer; far; external 'KERNEL' index 58; 
  178.       {$ENDIF}                                                       
  179.                                                                     
  180. Compile SYSUTILS for DOS PM from the command line:
  181.   DCC -cp SYSUTILS
  182.   
  183. It is all set to add the TPP.TPL and use in your programs.  I have not 
  184. been able to test every function that is provided.  It would be diffucult
  185. to get SysUtils working for DOS Real Mode because of its use of resource
  186. files, although I am sure it is possible if someone would like to give it 
  187. a shot.  You could probably remove all the exception handling and get it
  188. to compile with BP7.
  189.  
  190.  
  191.  
  192. -- Classes for DOS Protected Mode -----------------------------------------
  193. Getting the CLASSES unit to compile for DOS PM is very simple compared to
  194. SYSUTILS.  
  195.  
  196. In the INTERFACE section change the uses clause:
  197.   {$IFDEF WINDOWS}
  198.   uses SysUtils, WinTypes, WinProcs;
  199.   {$ELSE}
  200.   uses SysUtils, WinAPI;
  201.   {$ENDIF}
  202.  
  203. You need to create a unit called CONSTS that has the following:
  204. (This information was obtained via the online browser because
  205. Borland does not proved CONSTS.PAS - don't ask me why not!?):
  206. ========================================
  207. unit Consts;