This commit is contained in:
mpabi 2024-05-16 07:34:58 +01:00
parent b6c596ab49
commit f6c5d6164b
3 changed files with 64 additions and 36 deletions

View File

@ -2,10 +2,13 @@ TOP=./
include $(TOP)/Make.rules
LDLIBS=
CFLAGS+=-O0 -g
#CFLAGS+=-O0 -g
# CFLAGS+=-Og -ggdb3
CFLAGS+=-O0 -ggdb3
LDFLAGS+=-Wl,--no-relax
LDFLAGS+=-Wl,-Tdata=0x10000
LDFLAGS+=-Wl,-Ttext=0x80000000,-Tdata=0x80010000
# LDFLAGS+=-T murax_128k_ram.ld
PROGS=prog prog.bin prog.lst

View File

@ -9,7 +9,7 @@ _start:
la gp, __global_pointer$
.option pop
li sp, 0x1fff0
li sp, 0x800ffff0
# Clear the bss segment
la a0, __bss_start

View File

@ -1,48 +1,73 @@
#include <stdint.h>
//szymon
//#include "myfunc.h"
//int8_t x = 1, y = 2, z[10];
//int8_t *ip; /* ip to wskaźnik do obiektu typu int */
char * ptr1 = "janek";
char * ptr2 = "kowalskii";
void swap_ptr (int8_t *x, int8_t *y) {
int8_t tmp;
tmp = *x;
*x = *y;
*y = tmp;
int strlen(char *s)
{
char *p = s;
while (*p != '\0')
p++;
return p - s;
}
// -----------------------------------------------
void swap(int8_t x, int8_t y) {
int8_t tmp;
tmp = x;
x = y;
y = tmp;
void strcpy(char *s, char *t)
{
while (*s++ = *t++);
}
#define ALLOCSIZE 10000
static char allocbuf[ALLOCSIZE];
static char *allocp = allocbuf;
char *alloc(int n)
{
if (n % 4 != 0) {
n += 4 - (n % 4);
}
if (allocbuf + ALLOCSIZE - allocp >= n) {
allocp += n;
return allocp - n;
} else
return 0;
}
int main() {
// ip = &x; /* ip wskazuje teraz x */
// y = *ip; /* y ma teraz wartość 1 */
// *ip = 0; /* x ma teraz wartość 0 */
// ip = &z[0]; /* ip wskazuje teraz z[0] */
char * s = "mpabi";
uint8_t wynik =0;
wynik = strlen (s);
int8_t mx = 1, my = 2, mz[10]= {1,2,3,4,5};
int8_t *mip; /* ip to wskaźnik do obiektu typu int */
mip = &mx; /* ip wskazuje teraz x */
my = *mip; /* y ma teraz wartość 1 */
*mip = 0; /* x ma teraz wartość 0 */
mip = &mz[0]; /* ip wskazuje teraz z[0] */
asm("nop");
swap (mx, my);
swap_ptr (&mx, &my);
return 1;
char * p1 = alloc(strlen(ptr1));
strcpy (p1, ptr1);
asm("nop");
char * p2 = alloc(strlen(ptr2));
strcpy (p2, ptr2);
asm("nop");
struct point {
int16_t x;
int16_t y;
};
struct point * ptrS = (struct point *) alloc(sizeof(point));
ptrS->x=0x10;
ptrS->y=0x20;
asm("nop");
(*ptrS).y= strlen (p1)+ strlen(p2);
return 1;
}