Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4095
Number of posts: 14004

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Compiling to .COM format Posted by Frki on 30 Oct 2003 at 4:14 PM
Is there any way to compile Turbo Pascal 7.0 code to .COM file format ?
Report
Re: Compiling to .COM format Posted by Phat Nat on 31 Oct 2003 at 12:01 AM
: Is there any way to compile Turbo Pascal 7.0 code to .COM file format ?
:

Not directly I believe (correct me if I'm wrong).
You could, however, mark portions of code with assembly NOP functions and then pull the code out of the .EXE file and use DEBUG to convert it to assembly code that could be inserted into a TASM file.

Not really easy, but Turbo Pascal is a high level language and .COM files are built from low-level compilers.

I like to use markers like this:
Begin
     ASM NOP; NOP; NOP; END;
     GotoXY(12,4);   
     ASM NOP; NOP; NOP; END;
End.


Then after compiling, use your favorite editor to search for Ordinal value 144(x3) ()
There will be two sets of these in the file. One will be the start marker for the code, the other will be the end marker. Save it to a new file (such as CODE.OUT) and use "DEBUG CODE.OUT" to view the code as assembly.

Anyways, if you say exactly why you want to make it a com file, then we might be able to help more.

Phat Nat
Report
Re: Compiling to .COM format Posted by Frki on 1 Nov 2003 at 3:48 PM
I want to write a "Hello world" OS in Turbo Pascal. That is why I need to compile my code to .COM file format.

Best regards
Report
Re: Compiling to .COM format Posted by Phat Nat on 6 Nov 2003 at 1:16 AM
: I want to write a "Hello world" OS in Turbo Pascal. That is why I need to compile my code to .COM file format.
:
: Best regards
:

If you want to make a program to say "Hello, World!" and have it as small as possible, I suggest getting HELPPC (lots of good information) and writing it in DEBUG or some assembler. If I remember correctly, I managed to make a .COM file to do this that was 11 bytes large. It started out as inline assembly in Turbo Pascal (compiled the code section as 12 bytes), then took out a useless zero byte.

Anyways, I know that assembly is quite confusing the first time you see it, but HELPPC is a neccesity (Also covers hardware & c/c++ topics & functions).
Nor sure exactly where to get it, but try searching for "HELPPC David Jurgens" on your favorite search engine (such as http://www.metacrawler.com) It should return some hits for the program. If all fails, email me and I will send it to you.

Phat Nat

PS - Just write or email if you need a hand.
Report
Re: Compiling to .COM format - huh? Posted by Perran on 2 Nov 2003 at 4:48 AM
: : Is there any way to compile Turbo Pascal 7.0 code to .COM file format ?
: :
:
: Not directly I believe (correct me if I'm wrong).
: You could, however, mark portions of code with assembly NOP functions and then pull the code out of the .EXE file and use DEBUG to convert it to assembly code that could be inserted into a TASM file.
:
: Not really easy, but Turbo Pascal is a high level language and .COM files are built from low-level compilers.
:
: I like to use markers like this:
:
: Begin
:      ASM NOP; NOP; NOP; END;
:      GotoXY(12,4);   
:      ASM NOP; NOP; NOP; END;
: End.
: 

:
: Then after compiling, use your favorite editor to search for Ordinal value 144(x3) ()
: There will be two sets of these in the file. One will be the start marker for the code, the other will be the end marker. Save it to a new file (such as CODE.OUT) and use "DEBUG CODE.OUT" to view the code as assembly.
:
: Anyways, if you say exactly why you want to make it a com file, then we might be able to help more.
:
: Phat Nat
:
I'd like to point out that the first TP that I used [ver 3.0 in 1984] ONLY compiled .com files, and it should certainly be considered a high-level language. There was even a utility that came with DOS [exe2bin] that could convert most .exe files to .com. I do agree that most modern .exe files cannot be as easily converted.
Report
Re: Compiling to .COM format - huh? Posted by Phat Nat on 6 Nov 2003 at 1:21 AM
: : : Is there any way to compile Turbo Pascal 7.0 code to .COM file format ?
: : :
: :
: : Not directly I believe (correct me if I'm wrong).
: : You could, however, mark portions of code with assembly NOP functions and then pull the code out of the .EXE file and use DEBUG to convert it to assembly code that could be inserted into a TASM file.
: :
: : Not really easy, but Turbo Pascal is a high level language and .COM files are built from low-level compilers.
: :
: : I like to use markers like this:
: :
: : Begin
: :      ASM NOP; NOP; NOP; END;
: :      GotoXY(12,4);   
: :      ASM NOP; NOP; NOP; END;
: : End.
: : 

: :
: : Then after compiling, use your favorite editor to search for Ordinal value 144(x3) ()
: : There will be two sets of these in the file. One will be the start marker for the code, the other will be the end marker. Save it to a new file (such as CODE.OUT) and use "DEBUG CODE.OUT" to view the code as assembly.
: :
: : Anyways, if you say exactly why you want to make it a com file, then we might be able to help more.
: :
: : Phat Nat
: :
: I'd like to point out that the first TP that I used [ver 3.0 in 1984] ONLY compiled .com files, and it should certainly be considered a high-level language. There was even a utility that came with DOS [exe2bin] that could convert most .exe files to .com. I do agree that most modern .exe files cannot be as easily converted.
:


I think you're right. I do remember something along those lines (ah, DOS. Back when you didn't have to reload an operating system every couple months...) Worth checking the old DOS disks (if you still have them) to see about that file; of course it'd only run under a DOS formatted boot disk.

Phat Nat





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.