By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,826 Members | 2,384 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,826 IT Pros & Developers. It's quick & easy.

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

P: n/a
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);
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
intr(0x7a, &regs);
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?

Aug 5 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.