Pointers as array, copying to memory locations help
Well, basically the program should copy the ints a, b, c to destinations x, y, z.....
Haven't done C in a while and trying to get back on my feet.......
Pointers are getting somewhat confusing.....
The copy function was written way back....when I still knew C well...
The rest was written recently......
I put in nops as assembly as sort of, indentations in assembly so i can compare them to the C...
When you rarely speak a language, you forget it....i guess the same is true with programming languages....
Can someone help me debug this code........
Here is my code
Code:
#include <stdio.h>
int ptrcopy(int *src, int *dest, int len)
{
asm("nop");
int result = 0;
asm("nop");
while (len > 0) {
int val = *src++;
asm("nop");
*dest++ = val;
asm("nop");
result ^= val;
asm("nop");
len--;
asm("nop");
}
asm("nop");
return result;
}
int main()
{
asm("nop");
/* source */
int a = 0x123;
int b = 0x456;
int c = 0x789;
asm("nop");
/* destination */
int x = 0x111;
int y = 0x222;
int z = 0x333;
asm("nop");
int source = a;
int destination = x;
asm("nop");
printf( " %d \n", ptrcopy(source,destination,3) );
asm("nop");
}