#include <string.h>
#include <stdlib.h>
#define INT 2
#define LONG 4
#define TYPE 0
#define IF_(x) (x == 2 ? 2 : 4)
void test(void* x) {
int *ip;
char *cp;
byte *bp;
cp = memchr(x, 0, sizeof(long*));
*cp = 1;
*(cp + 1) = 1;
ip = x;
bp = x;
Serial.println(*bp);
Serial.println(*(bp + 0));
}
int test1(void* x) {
long *lp = x;
int ret = -1;
*lp = 0x7fffffff;
Serial.println(lp[0]);
Serial.println(lp[1]);
if(lp[0] = 0x7FFFFFFF) {
if(lp[1] == 0) { ret = 1; }
if(lp[1] != 0) { ret = 0; }
}
*lp = 0x00000000;
return ret;
}
void test2(void* x) {
long *lp = x;
*lp = 0x1ffff;
Serial.println(*lp);
lp++;
Serial.println(*lp);
}
void test3(void* x) {
int a[2] = {-1, 255};
void* vp[2] = {-1, 1};
int *ip;
char *cp;
byte *bp1;
byte *bp2;
int ret = 0;
// memcpy(x, a, sizeof(byte*) * 32);
bp1 = x;
*bp1 = ~(*bp1);
Serial.println(*(bp1 + 0));
Serial.println(*(bp1 + 1));
Serial.println(*(bp1 + 2));
Serial.println(*(bp1 + 3));
Serial.println();
// Serial.println(a[0]);
// Serial.println(a[1]);
// Serial.println(a[2]);
// Serial.println(a[3]);
}
int test4(void* x) {
byte *bp = x;
int count = 0;
for(int i = 0; i < 4; i++) {
if(*(bp + i) == 255) { count++; }
}
return count;
}
int test5(void *x) {
int *ip = x;
long *lp = x;
int ret = -1;
*lp = ~0;
if(*ip == -1) { ret = 2; }
if(*ip == 0) { ret = 4; }
return ret;
}
void test6(int a) {
#undef TYPE
#define TYPE 6
#if TYPE == 2
int b;
#elif TYPE == 4
long b;
#else
int b;
#endif
Serial.println(sizeof(b));
}
void test7(void *x) {
int *ip;
long *lp;
void *vp;
memmove(vp, x, 2);
Serial.println((int)vp);
}
void setup() {
Serial.begin(9600);
int num = 10;
int a[num] = {0};
long a1[num] = {0};
int *ip;
long *lp;
int i;
// for(i = 0; i < num; i++) { a[i] = 1; }
test7(a);
test7(a1);
// for(i = 0; i < num; i++) {
// Serial.print(a[i]);
// Serial.print(" ");
// }
// Serial.println();
// for(i = 0; i < num; i++) { Serial.println(a1[i]); }
}
void loop() {
// put your main code here, to run repeatedly:
}