473,783 Members | 2,516 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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(playsc ores, sizeof(playscor es), 0);//Pascal
memset(&playsco res, 0, sizeof(playscor es));//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?

Aug 5 '07 #1
0 1583

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
396
by: R BUckshaw | last post by:
Hello, I have been attempting to write a VB class that would expose its stuff to an older (ok, legacy application) program which can load and call exported functions from the old style dlls. With little documentation to go on, my legacy app defines a dll to load, then can call an exported function from the dll with up to 12 tokens on the call line. Appears to
4
4393
by: Chris Gordon-Smith | last post by:
I am tying to call a Pascal function from C++, and vice versa. Does anyone know how to do this, or where detailed information on this topic can be found? For the C++ to Pascal call I have tried declaring the Pascal function as:- extern "C" void PASCALTESTFUNC1(); within my C++ code. However, the linker is giving me an unresolved
0
1165
by: Ben | last post by:
I'm having some issues understanding the GAC. I have little doubt I've over complicated my problem, but here it is. I want to have a project reference an assembly in the GAC. Then I want to add a new version of that assembly to the GAC and have my project continue to use the old version. The problem is that it seems to immediately use the new version. I've tried deleting the reference from the solution explorer view and I've tried...
24
3481
by: Faith Dorell | last post by:
I really don´t like C.You can write better programs in BASIC than in C, if you don´t like this language. I don´t understand how C became so popular, although much better programming languages existed in the 70s or 80s or 90s. Pascal is much better.
1
1596
by: John Stemper | last post by:
Getting resource files to work with VS2002 and ASP.Net seems to be a little flaky. I've added a resource file "strings.resx" to the project. The properties of the files say Build action = "embedded resource". I've added the appropriate code to the Global.asax: protected void Application_Start(Object sender, EventArgs e) { Application = new ResourceManager("strings",Assembly.GetExecutingAssembly()); }
3
1968
by: Piripiccio | last post by:
Hello , please give me a little minute for this problem the first thing ..... my english is very bad I wrote a little program that using a socket pair with 2 process Padre (Father) and Figlio (Son) but the select see the future . This is the code ... please help me before i become crazy .....
1
2157
by: Sky | last post by:
Yesterday I was told that GetType(string) should not just be with a Type, but be Type, AssemblyName. Fair enough, get the reason. (Finally!). As long as it doesn't cause tech support problems down the line... What happens when my code is run on a station that only has framework 3.0 or 4.0, and this assembly, with version number defined for 2.0.0.0 , isn't available. ...breaks? Second question: Does an assembly's PublicKeyToken change...
5
3665
by: dhruba.bandopadhyay | last post by:
I am trying to port an old Pascal DOS game to DOS C/C++. I am wondering if anyone is familar with the dos & crt Pascal units and whether there are C/C++ equivalent libraries. Maybe dos.c & crt.c? Below lists names of variables, functions, types & weird interrupt procedures found in Pascal. Am wondering what can be done to get around them for use in C/C++. dos.pas crt.pas
1
2065
by: Andrew Wan | last post by:
I am having problems linking an assembly object with my C object files. Am getting: Linker Warning: DOSSEG directive ignored in module asm.asm Linker Error: Undefined symbol _ASMClsV in module main.c Linker Error: Undefined symbol VADDR in module asm.asm In my asm.asm file I've got: DOSSEG
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10081
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9946
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.