mirror of
https://github.com/yourtion/30dayMakeOS.git
synced 2026-04-26 19:49:50 +08:00
Add 30 day code
This commit is contained in:
1
30_day/stdlib/!cons_9x.bat
Normal file
1
30_day/stdlib/!cons_9x.bat
Normal file
@@ -0,0 +1 @@
|
||||
command
|
||||
1
30_day/stdlib/!cons_nt.bat
Normal file
1
30_day/stdlib/!cons_nt.bat
Normal file
@@ -0,0 +1 @@
|
||||
cmd.exe
|
||||
50
30_day/stdlib/Makefile
Normal file
50
30_day/stdlib/Makefile
Normal file
@@ -0,0 +1,50 @@
|
||||
OBJS_API = stdlib.obj
|
||||
|
||||
TOOLPATH = ../../z_tools/
|
||||
INCPATH = ../../z_tools/haribote/
|
||||
|
||||
MAKE = $(TOOLPATH)make.exe -r
|
||||
NASK = $(TOOLPATH)nask.exe
|
||||
CC1 = $(TOOLPATH)cc1.exe -I$(INCPATH) -Os -Wall -quiet
|
||||
GAS2NASK = $(TOOLPATH)gas2nask.exe -a
|
||||
OBJ2BIM = $(TOOLPATH)obj2bim.exe
|
||||
MAKEFONT = $(TOOLPATH)makefont.exe
|
||||
BIN2OBJ = $(TOOLPATH)bin2obj.exe
|
||||
BIM2HRB = $(TOOLPATH)bim2hrb.exe
|
||||
RULEFILE = ../haribote.rul
|
||||
EDIMG = $(TOOLPATH)edimg.exe
|
||||
IMGTOL = $(TOOLPATH)imgtol.com
|
||||
GOLIB = $(TOOLPATH)golib00.exe
|
||||
COPY = copy
|
||||
DEL = del
|
||||
|
||||
#默认动作
|
||||
|
||||
default :
|
||||
$(MAKE) stdlib.lib
|
||||
|
||||
#库生成规则
|
||||
|
||||
stdlib.lib : Makefile $(OBJS_API)
|
||||
$(GOLIB) $(OBJS_API) out:stdlib.lib
|
||||
|
||||
#文件生成规则
|
||||
|
||||
%.gas : %.c ../stdlib.h Makefile
|
||||
$(CC1) -o $*.gas $*.c
|
||||
|
||||
%.nas : %.gas Makefile
|
||||
$(GAS2NASK) $*.gas $*.nas
|
||||
|
||||
%.obj : %.nas Makefile
|
||||
$(NASK) $*.nas $*.obj $*.lst
|
||||
|
||||
#命令
|
||||
|
||||
clean :
|
||||
-$(DEL) *.lst
|
||||
-$(DEL) *.obj
|
||||
|
||||
src_only :
|
||||
$(MAKE) clean
|
||||
-$(DEL) stdlib.lib
|
||||
1
30_day/stdlib/make.bat
Normal file
1
30_day/stdlib/make.bat
Normal file
@@ -0,0 +1 @@
|
||||
..\..\z_tools\make.exe %1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||
51
30_day/stdlib/stdlib.c
Normal file
51
30_day/stdlib/stdlib.c
Normal file
@@ -0,0 +1,51 @@
|
||||
#include "../apilib.h"
|
||||
#include "../stdlib.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
int putchar(int c)
|
||||
{
|
||||
api_putchar(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
void exit(int status)
|
||||
{
|
||||
api_end();
|
||||
}
|
||||
|
||||
int printf(char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char s[1000];
|
||||
int i;
|
||||
|
||||
va_start(ap, format);
|
||||
i = vsprintf(s, format, ap);
|
||||
api_putstr0(s);
|
||||
va_end(ap);
|
||||
return i;
|
||||
}
|
||||
|
||||
void *malloc(int size)
|
||||
{
|
||||
char *p = api_malloc(size + 16);
|
||||
if (p != 0) {
|
||||
*((int *) p) = size;
|
||||
p += 16;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
void free(void *p)
|
||||
{
|
||||
char *q = p;
|
||||
int size;
|
||||
if (q != 0) {
|
||||
q -= 16;
|
||||
size = *((int *) q);
|
||||
api_free(q, size + 16);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Reference in New Issue
Block a user