HELP: Pascal & C/C++ (with a little assembly)

  • Thread starter dhruba.bandopadhyay
  • Start date
D

dhruba.bandopadhyay

Am using Borland C++ 4.5 for the old dos.h APIs. It appears that newer
versions of compilers stop support for the oldskool DOS routines. Am
trying to convert/port an oldskool Pascal program that uses registers/
interrupts into C/C++.


1. What are the inline($FA); & inline($FB); Pascal functions? What is
the C/C++ equivalent?
inline($CD / $1C);
inline($9C);


2. Just checking if this is correct Pascal-to-C conversion:

fillchar(playscores, sizeof(playscores), 0);//Pascal
memset(&playscores, 0, sizeof(playscores));//C

scrofsptr = addr(scr_ofs);//Pascal
scrofsptr = &(scr_ofs);//C

getintvec(0x9, oldkeyvec);//Pascal
getvect(0x9, oldkeyvec);//C

setintvec(0x9, addr(newkbdint()));//Pascal
setvect(0x9, &(newkbdint));//C

s = seg(dat);//Pascal
s = (unsigned int)dat & 0xFFFF0000;//C

o = ofs(dat);//Pascal
o = (unsigned int)dat & 0x0000FFFF;//C

port[0x40] = lo(count);//Pascal
outp( 0x40, lo(count) );//C

port[0x40] = hi(count);//Pascal
outp( 0x40, hi(count) );//C


3. dos.h contains a bunch of register structures.
My Pascal functions makes use of bx, es, si registers and this fits
nicely in struct REGPACK.
However some Pascal functions uses the 'al' register and struct
REGPACK doesn't have this member.

The union REGS gives me the 'al' register but doesn't provide a 'es'
register. See the dilemma?

It appears each function fills in a register struct and then calls
either:
intr(0x7a, &regs);
or
intr(0x2f, &regs);

Should I use the int386x() function since it takes 2 register
structures, one for input, one for output/result?

and then checks the 'al' member for the results.


4. How can I reverse the bits of a byte or word?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top