Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Compiling to .COM format

FrkiFrki Posts: 2Member
Is there any way to compile Turbo Pascal 7.0 code to .COM file format ?

Comments

  • Phat NatPhat Nat Posts: 757Member
    : 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:
    [code]
    Begin
    ASM NOP; NOP; NOP; END;
    GotoXY(12,4);
    ASM NOP; NOP; NOP; END;
    End.
    [/code]

    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
  • FrkiFrki Posts: 2Member
    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
  • PerranPerran Posts: 241Member
    : : 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:
    : [code]
    : Begin
    : ASM NOP; NOP; NOP; END;
    : GotoXY(12,4);
    : ASM NOP; NOP; NOP; END;
    : End.
    : [/code]
    :
    : 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.
  • Phat NatPhat Nat Posts: 757Member
    : 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.
  • Phat NatPhat Nat Posts: 757Member
    : : : 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:
    : : [code]
    : : Begin
    : : ASM NOP; NOP; NOP; END;
    : : GotoXY(12,4);
    : : ASM NOP; NOP; NOP; END;
    : : End.
    : : [/code]
    : :
    : : 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


Sign In or Register to comment.