URL
https://opencores.org/ocsvn/eco32/eco32/trunk
Subversion Repositories eco32
Compare Revisions
- This comparison shows the changes necessary to convert path
/eco32/tags/eco32-0.23/stdalone/twotasks-2/task2
- from Rev 18 to Rev 157
- ↔ Reverse comparison
Rev 18 → Rev 157
/c0.s
0,0 → 1,30
; |
; c0.s -- startup code and begin-of-segment labels |
; |
|
.import main |
|
.export _bcode |
.export _bdata |
.export _bbss |
|
.import _ecode |
.import _edata |
.import _ebss |
|
.code |
_bcode: |
|
.data |
_bdata: |
|
.bss |
_bbss: |
|
.code |
.align 4 |
|
start: |
jal main ; call 'main' function |
stop: |
j stop ; just to be sure... |
/c1.s
0,0 → 1,19
; |
; c1.s -- end-of-segment labels |
; |
|
.export _ecode |
.export _edata |
.export _ebss |
|
.code |
.align 4 |
_ecode: |
|
.data |
.align 4 |
_edata: |
|
.bss |
.align 4 |
_ebss: |
/task2.c
0,0 → 1,95
/* |
* task2.c -- a simple task |
*/ |
|
|
#include "putchar.h" |
#include "stdarg.h" |
|
|
/**************************************************************/ |
|
|
void puts(char *s) { |
char c; |
|
while ((c = *s++) != '\0') { |
putchar(c); |
} |
} |
|
|
void printn(int n) { |
int a; |
|
if (n < 0) { |
putchar('-'); |
n = -n; |
} |
a = n / 10; |
if (a != 0) { |
printn(a); |
} |
putchar(n % 10 + '0'); |
} |
|
|
void printu(unsigned int n, unsigned int b) { |
unsigned int a; |
|
a = n / b; |
if (a != 0) { |
printu(a, b); |
} |
putchar("0123456789ABCDEF"[n % b]); |
} |
|
|
void printf(char *fmt, ...) { |
va_list ap; |
char c; |
int n; |
unsigned int u; |
char *s; |
|
va_start(ap, fmt); |
while (1) { |
while ((c = *fmt++) != '%') { |
if (c == '\0') { |
va_end(ap); |
return; |
} |
putchar(c); |
} |
c = *fmt++; |
if (c == 'd') { |
n = va_arg(ap, int); |
printn(n); |
} else |
if (c == 'u' || c == 'o' || c == 'x') { |
u = va_arg(ap, int); |
printu(u, c == 'o' ? 8 : (c == 'x' ? 16 : 10)); |
} else |
if (c == 's') { |
s = va_arg(ap, char *); |
puts(s); |
} else { |
putchar(c); |
} |
} |
} |
|
|
/**************************************************************/ |
|
|
void main(void) { |
int i; |
|
printf("TASK2: executing...\n"); |
i = 0; |
while (1) { |
printf("TASK2: %d\n", i); |
i++; |
} |
} |
/putchar.s
0,0 → 1,10
; |
; putchar.s -- putchar library function |
; |
|
.code |
.export putchar |
|
putchar: |
trap |
jr $31 |
/stdarg.h
0,0 → 1,41
/* |
* stdarg.h -- variable argument lists |
*/ |
|
|
#ifndef _STDARG_H_ |
#define _STDARG_H_ |
|
|
typedef char *va_list; |
|
|
static float __va_arg_tmp; |
|
|
#define va_start(list, start) \ |
((void)((list) = (sizeof(start)<4 ? \ |
(char *)((int *)&(start)+1) : (char *)(&(start)+1)))) |
|
#define __va_arg(list, mode, n) \ |
(__typecode(mode)==1 && sizeof(mode)==4 ? \ |
(__va_arg_tmp = *(double *)(&(list += \ |
((sizeof(double)+n)&~n))[-(int)((sizeof(double)+n)&~n)]), \ |
*(mode *)&__va_arg_tmp) : \ |
*(mode *)(&(list += \ |
((sizeof(mode)+n)&~n))[-(int)((sizeof(mode)+n)&~n)])) |
|
#define _bigendian_va_arg(list, mode, n) \ |
(sizeof(mode)==1 ? *(mode *)(&(list += 4)[-1]) : \ |
sizeof(mode)==2 ? *(mode *)(&(list += 4)[-2]) : \ |
__va_arg(list, mode, n)) |
|
#define va_end(list) ((void)0) |
|
#define va_arg(list, mode) \ |
(sizeof(mode)==8 ? \ |
*(mode *)(&(list = (char*)(((int)list + 15)&~7U))[-8]) : \ |
_bigendian_va_arg(list, mode, 3U)) |
|
|
#endif /* _STDARG_H_ */ |
/putchar.h
0,0 → 1,13
/* |
* putchar.h -- putchar library function |
*/ |
|
|
#ifndef _PUTCHAR_H_ |
#define _PUTCHAR_H_ |
|
|
void putchar(char c); |
|
|
#endif /* _PUTCHAR_H_ */ |
/Makefile
0,0 → 1,21
BUILD = ../../../build |
|
all: task2 |
|
task2: c0.o task2.o putchar.o c1.o |
$(BUILD)/bin/ld -o task2 c0.o task2.o putchar.o c1.o |
|
c0.o: c0.s |
$(BUILD)/bin/as -o c0.o c0.s |
|
task2.o: task2.c |
$(BUILD)/bin/lcc -A -c -o task2.o task2.c |
|
putchar.o: putchar.s |
$(BUILD)/bin/as -o putchar.o putchar.s |
|
c1.o: c1.s |
$(BUILD)/bin/as -o c1.o c1.s |
|
clean: |
rm -f *~ c0.o task2.o putchar.o c1.o task2 |