Article View: alt.comp.lang.learn.c-c++
Article #313HELP: Pascal & C/C++ (with a little assembly)
From: dhruba.bandopadhyay
Date: Sun, 05 Aug 2007 18:49
Date: Sun, 05 Aug 2007 18:49
61 lines
3188 bytes
3188 bytes
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, ®s); or intr(0x2f, ®s); 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?
Technical Details
Message-ID:
<1186339773.983921.196040@l70g2000hse.googlegroups.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!l70g2000hse.googlegroups.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 114592,cccd2844f4f6a2df,start X-Google-Thread: f8d38,cccd2844f4f6a2df,start X-Google-Thread: 108ebd,cccd2844f4f6a2df,start X-Google-Thread: 1014db,cccd2844f4f6a2df,start X-Google-Thread: 111659,cccd2844f4f6a2df,start X-Google-Attributes: gid114592,gidf8d38,gid108ebd,gid1014db,gid111659,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!l70g2000hse.googlegroups.com!not-for-mail From: "dhruba.bandopadhyay@hotmail.com" <dhruba.bandopadhyay@hotmail.com> Newsgroups: alt.comp.lang.learn.c-c++,borland.public.cpp.language,borland.public.turbopascal,comp.lang.c,comp.lang.pascal.borland Subject: HELP: Pascal & C/C++ (with a little assembly) Date: Sun, 05 Aug 2007 11:49:33 -0700 Organization: http://groups.google.com Lines: 62 Message-ID: <1186339773.983921.196040@l70g2000hse.googlegroups.com> NNTP-Posting-Host: 86.2.245.208 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1186339774 440 127.0.0.1 (5 Aug 2007 18:49:34 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 5 Aug 2007 18:49:34 +0000 (UTC) User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: l70g2000hse.googlegroups.com; posting-host=86.2.245.208; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0