Author Topic: Simple example to link with DJGPP  (Read 450 times)

Gunther

  • Member
  • *****
  • Posts: 3720
  • Forgive your enemies, but never forget their names
Simple example to link with DJGPP
« on: March 06, 2021, 01:22:03 AM »
Has anyone a simple example for linking a jwasm OBJ file in coff format into DJGPP?

Gunther
Get your facts first, and then you can distort them.

Gunther

  • Member
  • *****
  • Posts: 3720
  • Forgive your enemies, but never forget their names
Re: Simple example to link with DJGPP
« Reply #1 on: March 08, 2021, 01:53:50 AM »
I had a problem the last days: How to include external routines written with JWASM for DOS into the DJGPP (GCC for DOS)? Apparently nobody is interested in this or
has experience with it. I could clarify this question and will show my solution here.

But first, a few thoughts on my part. The success or failure of a software does not depend on what the maintainers want as features. Much more important is what the users
need who use the software on a daily basis. As a maintainer you are well advised to listen to the masses of users and not only to exalted users from Portugal.

The success of JWASM has several sources. On the one hand, JWASM was 99% compatible with MASM. On the other hand JWASM ran on very different operating systems, even on
BSD, OS/2 and the good old DOS. Unfortunately this diversity does not exist anymore. Today you only have the choice between Windows, Linux and MacOS. (Does anyone really
think that the Apple famous for being famous uses UASM?)

How did it come about? Many will remember that years ago there was a difficult situation: New registers and instruction sets were introduced and the maintainer of JWASM was not
available. Therefore, according to my memory, Branislav took the initiative and dug into the sources of JWASM. The task was clearly outlined: The new instructions should be
implemented into JWASM - not more but also not less. I helped a little with the compilation of JWASM for DOS, but but not more.

Then I pulled out, because first the DOS version fell by the wayside and then some others. Instead more and more high level language constructs have been installed and JWASM
became UASM. I regret that direction very much, since one has robbed oneself of a source of success (variety of supported operating systems).

But there would have been enough work to do. Just look at the large amount of documentation that Hutch did for the MASM32 project! That is the standard that must be applied.
One could have begun also with the comments in the example programs; this has not been done until today.

I know very well that Hutch hesitated for a long time with MASM64, because he had the hope that UASM would mature. Very late he started with the new project and ML.
UASM had best chances for a long time, but did not take advantage of them.

Gunther
Get your facts first, and then you can distort them.

Gunther

  • Member
  • *****
  • Posts: 3720
  • Forgive your enemies, but never forget their names
Re: Simple example to link with DJGPP
« Reply #2 on: March 08, 2021, 01:59:35 AM »
So now back to the described problem. Under DOS there is not so much choice of good assemblers that fit to DJGPP. There is mainly NASM.
For some time YASM was a good and lean alternative, but it seems to me that there is no further development.

But there is still the last DOS version of JWASM. In my opinion it should work, if you include modules assembled with JWASM into the DJGPP.
Indeed, that works quite well.

My starting point was a simple test program by Matt Mastracci, where he linked a NASM procedure into a C++ program, including the fancy name mangling
and name decoration. I did this in a C program. There we set an integer variable, which is passed to the assembler procedure. That adds 4 to the value and
returns it to the main program to be printed. Nothing more happens.

This works with both NASM (no surprise there) and JWASM. I have tested the resulting programs under various configurations (DOSBox, VirtualBox,
VMWare Player, native DOS) and they run stable.

In the archive DJGPPASM there is the following structure:

DJGAPPASM\BINARY:  Contains the programs and object files.
DJGPPASM\CSource:   Contains the C source.
DJGPPASM\JWASM:    Contains the assembler source for JWASM.
DJGPPASM\NASM:      Contains the assembler source for NASM.

In each of the assembler directories is a batch file for compiling.

Finally a word about the file size of the EXE. It is a 32-bit application in protected mode. Therefore the extender (CWSDPMI) must be linked into the
application; this leads to the relatively large EXE files.

Gunther
Get your facts first, and then you can distort them.

TimoVJL

  • Member
  • ****
  • Posts: 695
Re: Simple example to link with DJGPP
« Reply #3 on: March 08, 2021, 05:50:35 AM »
msdos.exe with cwsdpmi.exe works badly, have to press enter before program shows result.

Open Watcom C supports 386 too.

Perhaps a useful link for people, who have to use MS DOS.
https://dosgames.com/utilities.php
« Last Edit: March 08, 2021, 08:30:45 AM by TimoVJL »
May the source be with you

Gunther

  • Member
  • *****
  • Posts: 3720
  • Forgive your enemies, but never forget their names
Re: Simple example to link with DJGPP
« Reply #4 on: March 08, 2021, 03:25:21 PM »
Timo,

msdos.exe with cwsdpmi.exe works badly, have to press enter before program shows result.

what is msdos.exe? The archive contains 2 running EXEs.

Much depends on your DOS configuration. I tested it with FreeDOS and had no problems. Do you have EMM386 installed or just HIMEM.SYS or is it a plain DOS?
I don't know where your problems come from at the moment, as I don't know your configuration.

But the DJGPP together with CWSDPMI was used to develop the famous game QUAKE. The two are a pretty solid team.

Gunther
Get your facts first, and then you can distort them.

Vortex

  • Member
  • *****
  • Posts: 2530
Re: Simple example to link with DJGPP
« Reply #5 on: March 08, 2021, 04:10:14 PM »
Hi Gunther,

I think msdos.exe must be the MS-DOS player :

Quote
This is MS-DOS emulator running on Win32-x64 command prompt.
16bit MS-DOS compatible commands can be executed on Win32-x64 envrionment.
http://takeda-toshiya.my.coocan.jp/msdos/index.html

Gunther

  • Member
  • *****
  • Posts: 3720
  • Forgive your enemies, but never forget their names
Re: Simple example to link with DJGPP
« Reply #6 on: March 08, 2021, 04:49:58 PM »
Erol,

I think msdos.exe must be the MS-DOS player :

Quote
This is MS-DOS emulator running on Win32-x64 command prompt.
16bit MS-DOS compatible commands can be executed on Win32-x64 envrionment.
http://takeda-toshiya.my.coocan.jp/msdos/index.html

probably. Thank you for the clarification. It's a similar concept as in DOSBox. But in DOSBox there are not such problems.

Gunther
Get your facts first, and then you can distort them.

TimoVJL

  • Member
  • ****
  • Posts: 695
Re: Simple example to link with DJGPP
« Reply #7 on: March 08, 2021, 06:14:20 PM »
Timo,

msdos.exe with cwsdpmi.exe works badly, have to press enter before program shows result.

what is msdos.exe? The archive contains 2 running EXEs.

Much depends on your DOS configuration. I tested it with FreeDOS and had no problems. Do you have EMM386 installed or just HIMEM.SYS or is it a plain DOS?
I don't know where your problems come from at the moment, as I don't know your configuration.

But the DJGPP together with CWSDPMI was used to develop the famous game QUAKE. The two are a pretty solid team.

Gunther
As Vortex mentioned, a MS-DOS Player for Win32-x64 was in my test.
DOSBox is good, it can control speed too.
May the source be with you

_japheth

  • Regular Member
  • *
  • Posts: 37
Re: Simple example to link with DJGPP
« Reply #8 on: March 09, 2021, 07:34:08 PM »
But there is still the last DOS version of JWASM.

jwasm is still developed, and there's still a DOS version - btw, the win32 version runs in DOS as well, with the HX extender ( the newest version of HX even runs 32-bit Uasm, linked with VS 2019, without problem ).
However, I abandoned Windows (desktop) programming several years ago, so this forum is not THAT much on my radar anymore.

Here's the link for jwasm DOS: https://github.com/Baron-von-Riedesel/JWasm/releases/download/v2.14/JWasm_v214_dos.zip
The road to hell is paved with good intentions.

Gunther

  • Member
  • *****
  • Posts: 3720
  • Forgive your enemies, but never forget their names
Re: Simple example to link with DJGPP
« Reply #9 on: March 09, 2021, 07:55:40 PM »
Thank you for the link.  :thumbsup:

Gunther
Get your facts first, and then you can distort them.