Serial port programming using Turbo C in WinXP

Hello,

I am trying to migrate Turbo C program from DOS old PC to WinXP PC. This program was develop years ago and uses int86x( 0x14, &IoRegs, &IoRegs, &segs ) to program 2 serial ports by doing write and read data, clear port input & output buffers, set port timeout value, and check port input buffer for data.

One of the serial port controls a device, the 2nd port communicates to a 2nd PC.

As an immediate short term solution, how can I update this DOS base Turbo c program to run on WinXP PC?

I will need to configure each port (will bioscom work for this or is it too low level)?

Also, I will need to update or replace these functions:

//clear input and output buffers of the port
IoRegs.h.ah = 9;
IoRegs.x.dx = com_port - 1;
int86x( 0x14, &IoRegs, &IoRegs, &segs );
return 0;

//set port timeout value
IoRegs.h.ah = 19;
IoRegs.x.bx = (int) (18 * TO_length);
IoRegs.x.dx = com_port - 1;
int86x( 0x14, &IoRegs, &IoRegs, &segs );
return 0;

//write a string to PC serial port
while(*string != 'x0') {
IoRegs.h.ah = 1;
IoRegs.h.al = (unsigned char) (*(string++));
IoRegs.x.dx = PC_PORT-1;
IoRegs.x.si = 0;
int86x( 0x14, &IoRegs, &IoRegs, &segs );
if ((IoRegs.h.ah & 0x80) == 0x80)
return ERROR;
n++;
}

//check input buffer for data
IoRegs.h.ah = 10;
IoRegs.x.dx = com_port - 1;
int86x( 0x14, &IoRegs, &IoRegs, &segs );
return IoRegs.x.ax;

//Read a packet or string from the serial port
while (n < MAX_RDDATA) {
IoRegs.h.ah = 2;
IoRegs.h.al = 0;
IoRegs.x.dx = com_port - 1;
IoRegs.x.si = 0;
int86x( 0x14, &IoRegs, &IoRegs, &segs );
if ((IoRegs.h.ah & 0x80) == 0x80)
break;
*(packet++) = IoRegs.h.al;
n++;
}

Help please.

Comments

  • I don't think you can do that stuff in Win32; if you need Win32 then you need to look up equivalent Win32 calls that do the same type of thing (but then you are asking permission of the OS to do it, which will slow things down a bit). Search for Win32 port stuff and see what you can find.
  • So the int86x 14H function set will not work on WinXP? What about Win98 or Win95?

    Can I use the bioscom function instead? Would it work on WinXP, W2K, NT, Win98?
  • If you are using a compiler that targets 386 type protected mode (as most do today), then a large amount of the old 16-bit bios stuff will just not work. The OS has taken over a large chunk of the low level operations and you have to ask it to do those things for you.

    You can do the things you want with an old 16-bit compiler, but you will be limited to 640K and the old memory models. The default memory model was "small", which is one 64K data segment and one 64K code segment. Most serious programs today need more.
  • I already address the size issue by using large model and allow for far pointers.

    So with the size limitation address, can these low level operation work in XP or 98 OSes?

    Can you clarify some questions for me:
    How do I ask the OS to do these operations for me?
    And would this be all windows type OS or some?
    Would the int86x function work in XP or 98 OS?
    If not would bioscom function work?


  • If you have an old 16-bit compiler, you can do this stuff under XP. Sounds like you do since you mention Turbo C.

    As for using a more modern compiler in protected mode -- use something like Visual Studio and look up some Win32 calls for doing port stuff. That is how you "ask the OS" to do things. I have experience moving a large 16 bit app to 32-bit protected mode and have run into all of these things. Sounds like you might as well use "tcc" and compile everything that way; you can still do the 16 bit stuff but modern compilers don't do that.
Sign In or Register to comment.

Howdy, Stranger!

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

Categories