building dos .COM apps lazarus / 8-Other ---------------------------------------------------------------------- RayH · 2009-09-20 11:26 I have a feeling that the answer to this isn't going to be quick or positive but... I have to maintain some code for an embedded pc system that controls some stepper motors and valves in a piece of equipment, and that communicates with a host computer via a serial link.  The code makes heavy use of the Port[] array for reading and writing to the hardware, as well as Intr functions/procedures. the first question is, is it possible to build .COM files (rather than .EXE's) using Lazarus (if so what version of lazarus/fpc do i need to install and what options do I need to tick) The second is, what files/units do I need to reference to get Port[] style access to memory and to use software interuppts using Intr() . Any help would be appreciated, I've had some experience using pascal on the mac a few years ago (using turbo pascal for mac 1.1, Think Pascal and Metroworks), but no PC Turbo Pascal experience (the app is currently in TP3.0).  I can get by in TP, but would love to be able to use the Lazarus IDE, since it offers the kind of features I used in Metrowerks (inspectors and browsers etc). Ray ---------------------------------------------------------------------- Ñuño_Martínez · 2009-09-22 09:49 AFAIK it isn't possible (if you're talking about the classic COM executable files). QDOS/MS-DOS COM executables where created to reduce memory to the minimum. They don't have header because the initialization was done by the operating system itself since all COM files used the same memory map. All COM files used the Tiny Memory Model which means the program and data fits in the same memory segment (64Kib IIRC). That is: the microprocessor must be in real mode and all calls, indirections and pointers must be 16bit wide. Since the Free Pascal compiler (used by Lazarus) is a 32bit compiler that memory model is just impossible. I've seen COM files bigger than 64Kib in the old MS-DOS days but they're tricky. Actually the OS loads a segment of the file (<= 64Kib). Everything else are data that are loaded by the program itself. May be the code twist the memory model to access beyond the 64Kib limits too. BTW I never saw a COM file that used the 32bit mode. I've seen COM files on FreeDOS but I'm not sure if they're using the same memory model that the one in the old times or they're actually EXE files that keeps the COM extension just for name compatibility with the old times. ---------------------------------------------------------------------- RayH · 2009-09-22 10:03 Thanks  Ñuño, looks like I'll have to keep this project in Turbo Pascal then - still there are a few other projects I have in mind that won't have this (.COM) constraint and I look forward to cutting my teeth on Lazarus for these. Ray ---------------------------------------------------------------------- alter · 2009-09-28 01:02 Quote from: Ñuño_Martínez on September 22, 2009, 11:49:16 amAFAIK it isn't possible (if you're talking about the classic COM executable files). QDOS/MS-DOS COM executables where created to reduce memory to the minimum. They don't have header because the initialization was done by the operating system itself since all COM files used the same memory map. All COM files used the Tiny Memory Model which means the program and data fits in the same memory segment (64Kib IIRC). That is: the microprocessor must be in real mode and all calls, indirections and pointers must be 16bit wide. Since the Free Pascal compiler (used by Lazarus) is a 32bit compiler that memory model is just impossible. And that is basically how even modern OS starts:-) Quote from: Ñuño_Martínez on September 22, 2009, 11:49:16 amI've seen COM files bigger than 64Kib in the old MS-DOS days but they're tricky. Actually the OS loads a segment of the file (<= 64Kib). Everything else are data that are loaded by the program itself. May be the code twist the memory model to access beyond the 64Kib limits too. BTW I never saw a COM file that used the 32bit mode. Since modern operating systems use 32 or 64 bit bootup code then it might be possible to have 32 bit memory map file. Quote from: Ñuño_Martínez on September 22, 2009, 11:49:16 amI've seen COM files on FreeDOS but I'm not sure if they're using the same memory model that the one in the old times or they're actually EXE files that keeps the COM extension just for name compatibility with the old times. There are 32 bit DOS systems that definitely have some changes with eventual backwards compatibility. Although no idea how it handles memory maps.