Hello,
I am trying a peice of code in VC++ which always worked in my embeded
compiler.
The code works fine when you pass it an address as we are suppossed to since
it takes a pointer. The code however did fail when its parameters come
directly from a structure. Now I would like to try this in VC++ and see if it
still fails to calculate.
However for me carry out the exact same test in VC++ 2003, I need to declare
8 bit type variables! I tried to use byte and small. I found the 8 bit type
coded this way:
__int8 or __int8 nsmall
However the calculation does not get carried out right!
Here is the code:
==========================================
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <stdlib.h>
#include <malloc.h>
struct xxx
{
__int8 a;
__int8 b;
__int8 c;
}d[]={0,0,1};
void INC_ADDR(
__int8 INCBY,
__int8 *A2,
__int8 *A1,
__int8 *A0)
{
short carry;
carry = (*A0 > 255 - INCBY); //If the calculation is true then carry = true
(*A0) += INCBY;
if (carry) {
++(*A1);
if ((*A1) == 0)
{
(*A2)++; }}
}
int main(void)
{
INC_ADDR( 176,
&(d[0].c),
&(d[0].b),
&(d[0].a));
INC_ADDR( 176,
&(d[0].c),
&(d[0].b),
&(d[0].a));
return 0;
}
=================================================
All help appreciated!
--
Best regards
Robert