XPost: alt.comp.lang.learn.c-c++   
   From: marcov@stack.nl   
      
   (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@hotmail.com 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.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|