init
This commit is contained in:
parent
b6c596ab49
commit
f6c5d6164b
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
|
||||
void swap_ptr (int8_t *x, int8_t *y) {
|
||||
|
||||
int8_t tmp;
|
||||
tmp = *x;
|
||||
*x = *y;
|
||||
*y = tmp;
|
||||
char * ptr1 = "janek";
|
||||
char * ptr2 = "kowalskii";
|
||||
|
||||
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";
|
||||
|
||||
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] */
|
||||
|
||||
swap (mx, my);
|
||||
swap_ptr (&mx, &my);
|
||||
uint8_t wynik =0;
|
||||
wynik = strlen (s);
|
||||
|
||||
return 1;
|
||||
asm("nop");
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue