hitcounter
dpointer
Thursday, February 24, 2005
 
OpenWatcom (and STLport)

The Watcom family of compilers always amazed me. First time I faced it years ago, when I was about to help my uncle debugging his program (this was WATFOR 77). Although Fortran was never my soul, it has ever caught my attention thanks to its wonderful features. Years after, knowing that DOOM was built using Watcom C/C++ compiler, I could imagine what kind of luxury it would offer; due to the fact that I have to live either with Borland C++ and/on DJGPP only.

When Watcom compilers became open-source, I was very exciting to try it out. But only lately I had time to examine it in details. OpenWatcom - that is the new name - is available from www.openwatcom.org. Unfortunately AFAIK the IDE has been ported to Linux yet, and the Windows version still resembles the look-and-feel for legacy Windows 3.1 application. But it works, and it works well.

I almost can not live without STL nowadays. Sadly the latest STLport still do not build with OpenWatcom. After searching around (WATCOM C/C++ Programmer's FAQ is highly recommended), I tried STLport modification from Peter Chapin's OpenWatcom page and it worked flawlessly.

The steps to install STLport follows. This assumes that you have downloaded the above mentioned STLport package for OpenWatcom.

Copy stlport subdirectory to your Watcom installation, e.g. to C:\Watcom

In file setvars.bat, modify the INCLUDE variable so that it becomes something like:

SET INCLUDE=C:\watcom\stlport;C:\watcom\H;C:\watcom\H\NT

Then you can start compiling your program that uses STL.

If, however, you use the IDE, then your project must have the stlport path before Watcom include files; else you will face billions of error messages. Use menu Sources, Source Options, C++ Compiler Switches to manage it.

Note: Seems that Peter Chapin's fixes for STLport are only for the 32-bit target platform (e.g. Win32). I am still trying to figure out how to modify this STLport so that I can also target DOS 32-bit.


Tuesday, February 22, 2005
 
I/O Port Access under Windows NT/2000/XP

Under DOS, you are free: you can directly access whatever hardware input/output ports you want to use. But with a real 32-bit operating system like Microsoft Windows NT family (this includes Windows 2000 and Windows XP), not longer you have such a wonderful freedom. Most of the time, you need to communicate with a device driver which then translates your commands and dispatches them properly to the device itself.

If you are stuck with legacy hardware, for which you would never ever find the corresponding device driver and/or you hesitate to waste your time and brain on writing one, a cheap solution exists: UserPort, which is "... a simple kernel mode driver for Windows NT/2000/XP that will give programs access to I/O ports..". Sounds perfect, right?

All you have to do is simple. Just grab UserPort.zip from the above mentioned link then extract it. Copy the file userport.sys to your Windows driver folder(e.g. c:\Windows\System32\Drivers). Then run userport.exe from where you can ranges of port addresses that you want to access directly. Click the Start button and you're done (though sometimes you need to restart the system).

Now this kind of prehistoric code will work even under Windows XP:

void outportb(unsigned int portid, unsigned char value)
{
  __asm mov edx,portid
  __asm mov al,value
  __asm out dx,al
}

void myfunction()
{
  char somevalue = 0x14;
  char anothervalue = 0x03;
  outportb( CARD_BASE_ADDRESS, somevalue );
  outportb( CARD_BASE_ADDRESS+1, anothervalue );
}


Powered by Blogger