/xenix: MS-DOS® Cross
Development
©1987 - Richard A. Bilancia - All Rights
Reserved
to be published first in the February 1988 issue of
UNIX®/World
One of the significant features of the versions of !!xenix!! for the Intel microprocessors has been the ability to develop !!ms-dos!! applications with an !!ms-dos!! library and !!ms-dos!! compatible compiler that are included with the standard !!xenix!! development system packages.
While I’ve known this fact for a long time, when Dr. Rebecca Thomas recently suggested that I write a column describing these cross development tools, I began to panic! I am not, nor have ever been, a serious !!ms-dos!! user (I can get by when I really need to do so). In fact, other than a single, simple compilation a long time ago I had never really used these cross development tools.
Fortunately, however, I did listen to Augie Hanson (a well known !!unix!!/!!ms-dos!! author and software developer) speak at the SCO Developers Conference last August. Since he has done extensive !!ms-dos!! cross development, he spoke on just that topic. I learned quite a bit from him, so let me share that with you. [Dianne, you might what an editor’s comment here that Augie will be doing some writing for !!unix!!/World in 1988.- Rich]
What’s the point?
One of the first questions often asked is, "...why, if you have a !!xenix!! system already, would you want to create an !!ms-dos!! program?" The answer can vary widely, but the sophisticated software development company that is developing !!ms-dos!! applications is usually the typical user.
Such companies often choose !!xenix!! to develop their applications because of the many !!ms-dos!!/!!xenix!! similarities with commands, I/O redirection and piping, device driver adaptation and the hierarchical file systems. But more importantly, they can take advantage of the !!xenix!! multitasking and multiuser capabilities to support many programmers working on the same application, as well as take advantage of the complete !!xenix!! development system editors and development and debugging tools. Additionally, version control is possible with !!xenix!! tools like **make** and **sccs** that are only available under !!ms-dos!! from third parties (an usually at a cost that approaches or exceeds the cost of the entire !!xenix!! operating system.
The one disadvantage often overlooked when selecting !!xenix!! as an !!ms-dos!! development environment is the absence of a good symbolic/visual debugger like the !!ms-dos!! based !!CodeView!!. Fortunately there is a way to develop !!ms-dos!! applications on !!xenix!! and still use !!CodeView!!. I’ll discuss that technique below.
The DOS Environment from !!xenix!!.
!!xenix!!, like many other implementations of !!unix!!, includes a set of program utilities that can access and update !!ms-dos!! diskettes. These utilities are essential to the use of the !!ms-dos!! cross development application tools described below. Accordingly, a short discussion of their use and application is in order.
The seven (7) utilities provided with the !!xenix!! runtime (the Development System is not required) that access !!ms-dos!! file systems are: **doscat** (which copies !!ms-dos!! files to the standard output), **doscp** (which copies files between !!ms-dos!! and !!xenix!! filesystems), **dosdir** (which lists !!ms-dos!! directories n !!ms-dos!! style), **dosls** (which lists !!ms-dos!! directories in !!xenix!! style), **dosrm** (which removes files from an !!ms-dos!! filesystem), **dosmkdir** (which makes directories in an !!ms-dos!! filesystem) and **dosrmdir** (which removes directories from an !!ms-dos!! filesystem). Of course, all of these commands are available as one is running the !!xenix!! operating system.
When using these commands it’s a wise idea to be aware that other !!xenix!! users might be able to access information on any such !!ms-dos!! filesystem. Accordingly, while not necessary you might want to also consider using the !!xenix!! **assign** command. The **assign**/**deassign** commands can be used to exclusively use any device (see the **assign(C)** manual page for limitations), but would be most commonly used with the system floppy disk drives when using the above !!ms-dos!! utilities.
For example, the following commands would assign the floppy disk drive number zero to the current user, the user should then insert a floppy diskette, the second command would list the root directory of the !!ms-dos!! diskette, the third command would copy an !!ms-dos!! file named "data" from from the !!ms-dos!! diskette to the user’s current working directory on the !!xenix!! system, and finally deassign the floppy disk device:
|
**assign fd0** |
|
|
**dosdir /dev/fd0:/** or **dosdir A:/** |
|
|
**doscp /dev/fd0:/data .** |
|
|
**deassign** |
The compiler and libraries.
Two things make the !!ms-dos!! cross development facility possible: the Microsoft **C** compiler and an !!ms-dos!! **C** library that is distributed with the !!xenix!! development system. The !!ms-dos!! **C** library in !!xenix!! includes 154 routines that are common to both the !!ms-dos!! and !!xenix!! operating systems. Additionally 51 !!ms-dos!! specific routines are also included. Both sets of routines are listed in the "!!xenix!!/!!ms-dos!! Cross Development" section of the "!!xenix!! Development System Programmer’s Guide II" and fully explained in "!!xenix!! Development System Programmer’s Reference (DOS)" manual pages. Most of these routines are called and return values that are consistent and identical in both environments, but there are a few that are different enough to cause a new cross developer some difficulty, so watch out!
All that is needed to develop an !!ms-dos!! executable from the !!xenix!! **C** compiler is to specify a single option to the Microsoft **C** compiler. The resulting file is directly executable from !!ms-dos!! but not !!xenix!!.
At this point it’s also important to note that if the !!xenix!! system is used to create any libraries using the **ar** command that such libraries are not compatible with the !!ms-dos!! loader.
An example.
Let’s assume that we’ve written the simple program, and created the file using a !!xenix!! editor on a !!xenix!! system, shown in Figure 1 called **test.c**. To compile and load this program so that it would execute on the !!xenix!! operating system, I would simply type:
|
**cc test.c** |
The resulting **a.out** file would look like this:
|
**-rwxr-xr-x 1 usr grp 7670 Oct 30 14:12 a.out** |
and the **file** command would describe it as:
|
**a.out: executable not stripped** |
To compile and load this program so that it would execute on the !!ms-dos!! operating system, I would simply type:
|
**cc -dos test.c** |
The resulting **a.out** file would look like this:
|
**-rwxr-xr-x 1 usr grp 5898 Oct 30 14:14 a.out** |
and the **file** command would describe it as:
|
**a.out: DOS executable** |
Lastly, to move this !!ms-dos!! executable file to an !!ms-dos!! diskette so that it could be executed from a **PC** running !!ms-dos!!, I might type something similar to the following set of commands:
|
**assign fd0** |
|
|
**doscp a.out A:/a.out |
|
|
**deassign** |
What’s next?
If you like the !!ms-dos!! cross development capabilities that I’ve described above, and are planning to develop applications for the new OS/2 operating system, you’ll be pleased to know a little inside information from the Santa Cruz Operation (SCO, Santa Cruz, CA). According to my sources at SCO, SCO is working closely with Microsoft (Redmond, WA) on including OS/2 cross development tools for the next major release of !!xenix!!. That next version, SCO !!xenix!! version 2.3, which is scheduled for release in the first quarter of 1988, will include OS/2 cross development tools.
Figure 1.
main()
{
|
printf("Hello UNIX/World readers!0); |
}