Announcement

Collapse
No announcement yet.

EXE2COM

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • EXE2COM

    Hi,

    I need to convert some PB DOS programs from EXE to COM. After a search, I fished up the following from Mel Bishop:

    Try BASM 286. I think it's available on PB downloads somewhere.
    It takes a basic style syntax and converts it to an actual .ASM
    file that you then run through MASM, LINK and, if necessary,
    EXE2COM.

    It was in response to a question about building a BASIC interpreter.

    I understand what the final product of the EXE2COM program "is" -- and I kind of know why I need a com file.

    I was just wondering what the "if necessary" part is, and why someone else might need to make a com out of an exe.

    Also, when I try the EXE2COM programs I have found, they all gripe about my simple little "Hello, World!" program having a stack.

    Is there a good way to keep my prog from having a stack?

    Mel?? are ya still out there?

    Ken


    ------------------
    Ken S. Elvehjem
    [email protected]
    Ken S. Elvehjem
    [email protected]

  • #2
    I'm not an expert in this area, but there are some things I have
    been lead to understand that may hold water and be useful for you
    to know. If I am in error on any point, I'm sure someone will
    set forth to correct me.

    COM programs are limited to one 64k segment. A stack has its own
    segment, which violates the convention. Most EXE programs cannot
    really convert because they have separate DATA and CODE segments,
    and many EXE's also exceed 64k in code (which is enabled by the
    $SEGMENT metacommand). COM programs are not designed to be
    relocatable either, and because of their simpler structure, DOS
    is unable to determine how much memory they need, so a COM is
    given all available memory by default, although it cannot readily
    use it. COM programs have to allocate portions of their own 64k
    segment for use as data and as a local stack.

    I am not sure why you need to have your code restricted to just
    the COM conventions, but this my help you understand that it may
    not be a trivial task to convert from EXE to COM. This might be
    possible if the data, structures, combined code segments, and
    set aside stack space (which is controlled by $STACK metacommand)
    can be consolidated into one single 64k segment. Note that if
    you exceed this limit, your program will not convert.

    It's interesting to note that if you call a program without its
    extention, such as PROGRAMX, and if there is an PROGRAMX.BAT,
    PROGRAMX.COM, and PROGRAMX.EXE file at the same point in the
    searched path, then the BAT file is the one that will be loaded
    and executed. If there is no BAT file at that point, then the
    COM file will be executed instead. That is the execution
    preference if all three, or any two are present together. I once
    had a program that used this to "trick" the system by having the
    BAT file set up the environment, then call the program COM file
    which automatically allocated all available memory to the
    program, then that in turn explicitly called the EXE which was
    then able to perform the desired tasks. An unusual arrangement
    to say the least, and it depended on either always initiating
    the program with PROGRAMX or PROGRAMX.BAT. If you manually
    called PROGRAMX,COM, you would not get the environment settings
    needed, and if you manually called PTOGRAMX.EXE, you would not
    get the right environment or the availability of all memory.

    I believe that later versions of DOS, particularly those that
    support Windows, stopped the full allocation of memory to a COM
    program when loaded, as that would be intollerable in an
    environment set up to do multitasking, but I really haven't
    paid much attention to this issue, since it was a poor practice
    and the program that did it finally got religated to the dump.

    ------------------
    Old Navy Chief, Systems Engineer, Systems Analyst, now semi-retired

    Comment


    • #3
      Donald,

      Thank you for the reply. You have at least quadrupled my understanding of the subject with your clear explanation!

      My reason for wanting a COM file is that I purchased a little controller (A2D, TTL I/O, Serial, Parallel, KeyPad, LCD readout, etc.) called a Volkscomputer from the people at MVS ( http://www.star.net/people/~mvs/ ) -- talk about some cool gadgets.

      They have at least 3 "controllers" -- maybe more -- for which they advertise the ability to write and debug a program on th PC, and download it to the controller.

      It *has* to be a COM file.

      So I thought I would take advantage of the PowerBasic for DOS to produce an EXE file, and convert it to a COM file. (I did that once with QuicBasic, in the distant past)

      The MVS people have a lot of short sample programs written in Assembler, and my hope is that I can just sort of "weld" together the ones that I need in a PB program, compile, convert, and download. Guess *that* may not happen.

      They have all the tools to "do" assembly (assemble, link) -- and I suppose I can do that. Won't be as much fun...

      Ken

      ------------------
      Ken S. Elvehjem
      [email protected]
      Ken S. Elvehjem
      [email protected]

      Comment


      • #4
        PowerBasic for DOS to produce an EXE file, and convert it to a
        COM
        Don's reply is most excellent!!!

        Can't be done my friend. PB/DOS is it's own compiler and the .EXE
        it produces can't be converted.

        If you absolutely have to have a .COM program, the only way I know
        of is to write your own in .ASM and compile it through the process
        mentioned above. (or maybe some flavor of C.)

        BASM 286 is, to the best of my knowledge, not available any more.
        At the request of the author, it's been deleted from PB's download
        section and I can't find it available on the net anywhere.

        The "if necessary" part is simply how the source code is structured.
        I'm kind of hazzy on this part now but the structure of a .COM
        program is a little different from producing an EXE program. You
        can write a program that is designed to be converted to COM or write
        it another way to leave it as an EXE.


        ------------------
        There are no atheists in a fox hole or the morning of a math test.
        If my flag offends you, I'll help you pack.

        Comment


        • #5
          Originally posted by Mel Bishop:
          BASM 286 is, to the best of my knowledge, not available any more.
          At the request of the author, it's been deleted from PB's download
          section and I can't find it available on the net anywhere.
          [/B]
          I asked PowerBasic to remove BASM286 because it is now free and open
          source available at the bottom of this webpage: http://www.bcxgurus.com

          Although clearly weaker than PowerBasic, BASM does allow you to
          choose between COM or EXE code emission, effectively eliminating the
          questionable need and frustration of using the EXE2COM tool altogether.

          ------------------
          http://www.bcxgurus.com/

          [This message has been edited by Kev Diggins (edited February 27, 2007).]
          http://www.bcxgurus.com/

          Comment


          • #6
            Originally posted by Kev Diggins:
            ...source available...this webpage...
            Thanks for the link, Kev. I had a total hard drive crash some
            time ago and lost everything. Didn't have a current backup, so,
            been looking for it every since.

            Downloaded and backed up thrice.



            ------------------
            There are no atheists in a fox hole or the morning of a math test.
            If my flag offends you, I'll help you pack.

            Comment


            • #7
              Donald, Kev, and Mel:

              Thanks very much for your replies. It looks like I'm about to navigate another learning curve... but that's OK... it's what keeps the grey matter flexible and stirred up!

              Kev, I noted in the BASM.TXT file that I need a "val" and "asm"... where can I get them?

              Sincerely,

              Ken


              ------------------
              Ken S. Elvehjem
              [email protected]
              Ken S. Elvehjem
              [email protected]

              Comment


              • #8
                Originally posted by Ken Elvehjem:

                Kev, I noted in the BASM.TXT file that I need a "val" and "asm"... where can I get them?
                Ken,

                The Internet Wayback Machine is a mind blowing experience
                Here is a working webpage (with download links) from 2002
                http://web.archive.org/web/200112020...net/~sdiggins/

                Alternatively, I think you may still be able to download the final
                Turbo C for DOS directly from www.borland.com (free of charge) and
                use the Turbo assembler and Turbo linker that was included in the
                \bin\ folder.

                Have Fun!

                ------------------
                http://www.bcxgurus.com/
                http://www.bcxgurus.com/

                Comment


                • #9
                  Kev,

                  I know what you mean about the Internet... Almost didn't find *my* WayBack one time.

                  Regards to Sherman and Mr. Peabody, And thanks much for the lynx.

                  Sincerely,

                  Ken


                  ------------------
                  Ken S. Elvehjem
                  [email protected]
                  Ken S. Elvehjem
                  [email protected]

                  Comment


                  • #10
                    Can you just use PDQ by Ethan Winer? http://www.ethanwiner.com/p_pdq.htm
                    ------------------


                    [This message has been edited by Mike Doty (edited February 28, 2007).]
                    The world is full of apathy, but who cares?

                    Comment


                    • #11
                      Mike,

                      Do you use the PDQ product? Comments about the PDQ?

                      If so, could you tell me how many bytes a simple 3 line "Hello, World!" program comes out as?

                      Maybe like this:

                      DIM K as String
                      K = "Hello, World!"
                      Print k

                      Thanks,

                      KEn


                      ------------------
                      Ken S. Elvehjem
                      [email protected]
                      Ken S. Elvehjem
                      [email protected]

                      Comment


                      • #12
                        Kev,

                        Was unable to unzip the FREETC20.zip and the arrow zip files. Any advice?

                        Sincerely,

                        Ken

                        ------------------
                        Ken S. Elvehjem
                        [email protected]
                        Ken S. Elvehjem
                        [email protected]

                        Comment


                        • #13
                          Originally posted by Ken Elvehjem:
                          Kev,
                          Was unable to unzip the FREETC20.zip and the arrow zip files.
                          Any advice?
                          Sincerely,
                          Ken
                          Check your email ...

                          ------------------
                          http://www.bcxgurus.com/
                          http://www.bcxgurus.com/

                          Comment


                          • #14
                            4942, but I'm missing _NOREAD.OBJ and other stubs to make it smaller.

                            ------------------




                            [This message has been edited by Mike Doty (edited March 02, 2007).]
                            The world is full of apathy, but who cares?

                            Comment


                            • #15
                              Originally posted by Mike Doty:
                              4942, but I'm missing _NOREAD.OBJ and other stubs to make it smaller.
                              ----------------
                              Save to Test.Bas
                              ----------------
                              $COM 'generate code for COM model
                              K$ = "Hello,World"
                              PRINT K$


                              BASM test
                              TASM test
                              TLINK test /t

                              produces Test.Com ... Test.Com = 354 bytes.

                              BASM wins



                              ------------------
                              http://www.bcxgurus.com/
                              http://www.bcxgurus.com/

                              Comment


                              • #16
                                I guess this is what you are looking for. However remember Donald's comment.
                                Code:
                                EXECOM 10.0: EXE-to-COM converter
                                FREE!!!
                                Download ExeC1000.zip
                                Like the old DOS utility, EXE2BIN, this program converts .EXE files to .COM files. It's smaller and faster, though, as well as offering a few additional conveniences. The latest version supports long filenames under Windows 95, et al., although it works equally well under old versions of DOS.
                                EXECOM includes full source code in MASM-compatible assembly language.
                                http://www.tgh3.com/

                                More here (look out for virii!!): http://www.google.dk/search?hl=da&q=...+convert&meta=

                                Cheers,
                                Tonny

                                ------------------

                                Comment


                                • #17
                                  Kev,

                                  Works great! the COM file is, well, microscopic. The only hitch was a warning error generated from TASM. I redirected the batch file output to a text file and came up with what follows:

                                  *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#
                                  C:\FromKev>call basm test

                                  C:\FromKev>call tasm test
                                  Turbo Assembler Version 1.01 Copyright (c) 1988, 1989 Borland International

                                  Assembling file: TEST.ASM
                                  *Warning* TEST.ASM(262) Reserved word used as symbol: ERR
                                  Error messages: None
                                  Warning messages: 1
                                  Remaining memory: 481k


                                  C:\FromKev>call tlink test /t
                                  Turbo Link Version 2.0 Copyright (c) 1987, 1989 Borland International

                                  *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#

                                  Sincerely,

                                  Ken

                                  ------------------
                                  Ken S. Elvehjem
                                  [email protected]
                                  Ken S. Elvehjem
                                  [email protected]

                                  Comment


                                  • #18
                                    Mike,

                                    Missed the *4942* part of your reply... not up on codes, and do you know how many "4942" items google lists? :> )

                                    Ken


                                    ------------------
                                    Ken S. Elvehjem
                                    [email protected]
                                    Ken S. Elvehjem
                                    [email protected]

                                    Comment


                                    • #19
                                      Code:
                                      1) No, I haven't used PDQ for a long time and am missing the stub files
                                         to make files even smaller so I can't link with those files.
                                      2) It was an answer to the question.  How many bytes?
                                         The PDQ page compares different products.

                                      ------------------
                                      The world is full of apathy, but who cares?

                                      Comment


                                      • #20
                                        OK, thanks.

                                        I guess I missed that.

                                        Ken


                                        ------------------
                                        Ken S. Elvehjem
                                        [email protected]
                                        Ken S. Elvehjem
                                        [email protected]

                                        Comment

                                        Working...
                                        X