struct/cpp/_rvmain.cpp

70 lines
951 B
C++
Raw Normal View History

2024-03-18 10:11:23 +00:00
#include <stdint.h>
2024-05-16 06:34:58 +00:00
char * ptr1 = "janek";
char * ptr2 = "kowalskii";
2024-03-18 10:11:23 +00:00
2024-05-16 06:34:58 +00:00
int strlen(char *s)
{
char *p = s;
while (*p != '\0')
p++;
return p - s;
}
2024-03-26 09:29:31 +00:00
2024-05-16 06:34:58 +00:00
void strcpy(char *s, char *t)
{
while (*s++ = *t++);
2024-03-26 09:29:31 +00:00
}
2024-05-16 06:34:58 +00:00
#define ALLOCSIZE 10000
2024-03-26 09:29:31 +00:00
2024-05-16 06:34:58 +00:00
static char allocbuf[ALLOCSIZE];
static char *allocp = allocbuf;
char *alloc(int n)
{
2024-03-26 09:29:31 +00:00
2024-05-16 06:34:58 +00:00
if (n % 4 != 0) {
n += 4 - (n % 4);
}
if (allocbuf + ALLOCSIZE - allocp >= n) {
allocp += n;
return allocp - n;
} else
return 0;
}
2024-03-26 09:29:31 +00:00
2024-05-17 10:13:06 +00:00
int32_t sum (int32_t a, int32_t b) {
2024-05-16 06:34:58 +00:00
2024-05-17 10:13:06 +00:00
return a+b;
}
2024-05-16 06:34:58 +00:00
2024-05-17 10:13:06 +00:00
int main() {
2024-05-16 06:34:58 +00:00
struct point {
2024-05-17 10:13:06 +00:00
int32_t x;
int32_t y;
2024-05-16 06:34:58 +00:00
};
2024-03-18 10:11:23 +00:00
2024-05-17 10:13:06 +00:00
struct point * ptrS;
ptrS = (struct point *) alloc(sizeof(point));
asm("nop");
2024-05-16 06:34:58 +00:00
ptrS->x=0x10;
ptrS->y=0x20;
2024-03-18 10:11:23 +00:00
2024-05-17 10:13:06 +00:00
int32_t wynik = 0;
wynik = sum ( (*ptrS).x, ptrS->y);
asm("nop");
2024-03-26 09:29:31 +00:00
2024-05-16 06:34:58 +00:00
return 1;
2024-03-18 10:11:23 +00:00
}