Pascal to C++

R

rod_oconor

Hey,

Im doing a project which invoves using a serial A/D converter, I have
been given some C code in Pascal but i need this translated into C++
code in order to use it in the compiler that i have been told to use, I
am only new to both types of code and any help you could give me would
be greatly appreciated,

Thanks in advance,

Rod

The code is as shown here

Program serial_adc;

{Serial port AD converter circuit control program by Tomi Engdahl}

Uses Crt;

Const
combase=$2f8;
MCR=combase+4;
LCR=combase+3;
MSR=combase+6;

Procedure Initialize_converter;
Begin
Port[MCR]:=3;
Port[LCR]:=0;
End;

Function Read_value:byte;
Var
value:byte;
count:byte;
Begin
value:=0;
Port[MCR]:=1;
For count:=0 to 7 Do Begin
value:=value SHL 1;
Port[LCR]:=64;
If (port[MSR] and $10)=$10 Then Inc(value);
Port[LCR]:=0;
End;
Port[MCR]:=3;
Read_value:=value;
End;

Begin
Initialize_converter;
Repeat
Writeln(Read_value);
Until KeyPressed;
End.
 
H

Howard

Hey,

Im doing a project which invoves using a serial A/D converter, I have
been given some C code in Pascal but i need this translated into C++
code in order to use it in the compiler that i have been told to use, I
am only new to both types of code and any help you could give me would
be greatly appreciated,

You've got C code in Pascal? I'm not sure what that means...? :)

The code below is not something that can be translated into "standard" C++
code, which is what this forum discusses. It contains several things for
which you'll need some third-party software or platform API for, such as
direct memory access (for which you may need special hardware driver
software, if you're running something like Windows XP), and for checking
keypresses.

You might ask on a newsgroup devoted to the platform you're working under.

-Howard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top