www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/12/14/08:36:59

From: "=?iso-8859-1?Q?Veli-Pekka_Kilpel=E4inen?=" <vpk2 AT sci DOT fi>
To: <djgpp AT delorie DOT com>
Subject: Incorrect increment?
Date: Mon, 14 Dec 1998 15:34:59 +0200
Message-ID: <01be2766$8b88d320$0a034ac3@vpk2.sci.fi>
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 4.71.1712.3
X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3
Reply-To: djgpp AT delorie DOT com

This is a multi-part message in MIME format.

------=_NextPart_000_0020_01BE2777.4F11A320
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I don't have a C++ book so try to bear me.

I'm having a problem trying to increment a pointer of type unsigned =
char. When I use Rhide's debugger and moving step by step(F8) while =
monitoring the pointers "value" I see that instead of moving one byte =
foward, it'll go three. Here's a cutout from my file:

void movemydata(int max, unsigned char *pointertodata)
{
...
_farsetsel(_dos_ds);
for (int index =3D 0; index < max; index++)
 {if ( (index & 3) =3D=3D 3)
  {pointertodata++;   // yes, I'm trying to skip=20
  destinteger++;}     // every fourth byte.
 else  {_farnspokeb(destinteger++, *pointertodata);
  pointertodata++;}   // yes, I've put it here to verify=20
 };           // I'm incrementing the pointer.
...
}

It would be nice if you'd answer these too:
-Am I getting into trouble when not restoring the original selector?
-The size of variables differ from what my tutorial says - integers are =
not two bytes long. Does this depend on the enviroment? Mine is PC =
Pentium. How do I get one byte long integers?
-What will happen if I "overload" my integers trying to put too big =
number in it?

------=_NextPart_000_0020_01BE2777.4F11A320
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>

<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type>
<META content=3D'"MSHTML 4.71.2016.0"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT color=3D#000000 face=3DArial size=3D2>I don't have a C++ book =
so try to=20
bear me.</FONT></DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2>I'm having a problem =
trying to=20
increment a pointer of type unsigned char. When I use Rhide's debugger =
and=20
moving step by step(F8) while monitoring the pointers &quot;value&quot; =
I see=20
that instead of moving one byte foward, it'll go three. Here's a cutout =
from my=20
file:</FONT></DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2>void movemydata(int =
max, unsigned=20
char *pointertodata)<BR>{<BR>...<BR>_farsetsel(_dos_ds);<BR>for (int =
index =3D 0;=20
index &lt; max; index++)<BR> {if ( (index &amp; 3) =3D=3D 3)<BR>&nbsp;=20
{pointertodata++;&nbsp;&nbsp; // yes, I'm trying to skip <BR>&nbsp;=20
destinteger++;}&nbsp;&nbsp;&nbsp;&nbsp; // every fourth byte.<BR> =
else&nbsp;=20
{_farnspokeb(destinteger++, *pointertodata);<BR>&nbsp;=20
pointertodata++;}&nbsp;&nbsp; // yes, I've put it here to verify <BR>=20
};&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // I'm=20
incrementing the pointer.<BR>...<BR>}</FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2>It would be nice if =
you'd answer=20
these too:<BR>-Am I getting into trouble when not restoring the original =

selector?<BR>-The size of variables differ from what my tutorial says - =
integers=20
are not two bytes long. Does this depend on the enviroment? Mine is PC =
Pentium.=20
How do I get one byte long integers?<BR>-What will happen if I=20
&quot;overload&quot; my integers trying to put too big number in=20
it?</FONT>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_0020_01BE2777.4F11A320--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019