Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Pascal Borland > Re: HELP: Pasca...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 1044 of 1102
Post > Topic >>

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

by Marco van de Voort <marcov@[EMAIL PROTECTED] > Aug 6, 2007 at 07:33 AM

(newsgroups list severely trimmed. Borland.* won't see our reactions,
and this kind of stuff can be found in so many faqs that I won't bother
c.l.c with it)

On 2007-08-05, dhruba.bandopadhyay@[EMAIL PROTECTED]
> wrote:
> 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);

inline just inlines the bytes in the code stream. IOW they are pure
machinecode in hex. Probably STI/CLI or so.

Just put them as 

db $FA,$FB,$CD,$1C,$9C

in the code segment in some assembler, and then disassemble the assembled
result.

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

The first ones look correct.

> s = seg(dat);//Pascal
> s = (unsigned int)dat & 0xFFFF0000;//C
>
> o = ofs(dat);//Pascal
> o = (unsigned int)dat & 0x0000FFFF;//C

There is no universal translation for these. They all depend on memory 
models and what you want to do with the result. 

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

Count must be a 16-bit type.

> 3. dos.h contains a bunch of register structures.
> 4. How can I reverse the bits of a byte or word?

I don't know the relevant C functions of this, so can't answer this.

I seriously wonder why this is worth the trouble btw, 16-bits dos being
pretty dead.




 1 Posts in Topic:
Re: HELP: Pascal & C/C++ (with a little assembly)
Marco van de Voort <ma  2007-08-06 07:33:52 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon May 12 21:33:35 CDT 2008.