Kaynağa Gözat

Added entry points for ANSI C

ceriel 34 yıl önce
ebeveyn
işleme
545b54b4c7

+ 25 - 1
lang/cem/libcc/mon/LIST

@@ -22,7 +22,6 @@ execl.e
 execle.e
 execv.e
 execve.e
-_exit.e
 fork.e
 fstat.e
 ftime.e
@@ -62,3 +61,28 @@ utime.e
 wait.e
 write.e
 errno.e
+_alarm.e
+_brk.e
+_close.e
+_creat.e
+_dup.e
+_dup2.e
+_execl.e
+_exit.e
+_fork.e
+_fstat.e
+_ftime.e
+_getpid.e
+_gtty.c
+_ioctl.e
+_kill.e
+_link.e
+_lseek.e
+_open.e
+_pause.e
+_pipe.e
+_read.e
+_sbrk.e
+_unlink.e
+_wait.e
+_write.e

+ 9 - 0
lang/cem/libcc/mon/_alarm.e

@@ -0,0 +1,9 @@
+#
+ mes 2,EM_WSIZE,EM_PSIZE
+ exp $_alarm
+ pro $_alarm,0
+ lol 0
+ loc 27
+ mon
+ ret EM_WSIZE
+ end

+ 54 - 0
lang/cem/libcc/mon/_brk.e

@@ -0,0 +1,54 @@
+#
+#include <em_abs.h>
+
+ mes 2,EM_WSIZE,EM_PSIZE
+
+.1
+ bss EM_PSIZE,0,0
+.2
+ bss EM_WSIZE,0,0
+
+ pro $ctch,0
+ lol 0
+ loc EHEAP
+ beq *1
+ lae .1
+ loi EM_PSIZE
+ sig
+ asp EM_PSIZE
+ lol 0
+ trp
+ rtt
+1
+ loc 1
+ ste .2
+ rtt
+ end
+
+
+ exp $_brk
+ pro $_brk,0
+ lpi $ctch
+ sig
+ lae .1
+ sti EM_PSIZE
+ loc 0
+ ste .2
+ lal 0
+ loi EM_PSIZE
+ str 2          ; The - possibly - occurring trap is caught
+ lae .1
+ loi EM_PSIZE
+ sig
+ asp EM_PSIZE
+ loe .2
+ zgt *1
+ zer EM_PSIZE
+ ret EM_PSIZE
+1
+ loc -1
+ loc EM_WSIZE
+ loc EM_PSIZE
+ cii
+ ret EM_PSIZE
+ end

+ 15 - 0
lang/cem/libcc/mon/_close.e

@@ -0,0 +1,15 @@
+#
+ mes 2,EM_WSIZE,EM_PSIZE
+ exp $_close
+ pro $_close,0
+ lol 0
+ loc 6
+ mon
+ zne *1
+ loc 0
+ ret EM_WSIZE
+1
+ ste errno
+ loc -1
+ ret EM_WSIZE
+ end

+ 14 - 0
lang/cem/libcc/mon/_creat.e

@@ -0,0 +1,14 @@
+#
+ mes 2,EM_WSIZE,EM_PSIZE
+ exp $_creat
+ pro $_creat,0
+ lal 0
+ loi EM_WSIZE+EM_PSIZE
+ loc 8
+ mon
+ zeq *1
+ ste errno              ; since e==r0
+ loc -1
+1
+ ret EM_WSIZE
+ end

+ 14 - 0
lang/cem/libcc/mon/_dup.e

@@ -0,0 +1,14 @@
+#
+ mes 2,EM_WSIZE,EM_PSIZE
+ exp $_dup
+ pro $_dup,0
+ lol 0
+ _dup EM_WSIZE
+ loc 41
+ mon
+ zeq *1
+ ste errno
+ loc -1
+1
+ ret EM_WSIZE
+ end

+ 16 - 0
lang/cem/libcc/mon/_dup2.e

@@ -0,0 +1,16 @@
+#
+ mes 2,EM_WSIZE,EM_PSIZE
+ exp $_dup2
+ pro $_dup2,0
+ lal 0
+ loi 2*EM_WSIZE
+ loc 64
+ ior EM_WSIZE
+ loc 41
+ mon
+ zeq *1
+ ste errno
+ loc -1
+1
+ ret EM_WSIZE
+ end

+ 15 - 0
lang/cem/libcc/mon/_execl.e

@@ -0,0 +1,15 @@
+#
+ mes 2,EM_WSIZE,EM_PSIZE
+ exp $_execl
+ pro $_execl,0
+ lae _penvp
+ loi EM_PSIZE
+ lal EM_PSIZE
+ lal 0
+ loi EM_PSIZE
+ loc 59
+ mon
+ ste errno
+ loc -1
+ ret EM_WSIZE
+ end

+ 18 - 0
lang/cem/libcc/mon/_fork.e

@@ -0,0 +1,18 @@
+#
+ mes 2,EM_WSIZE,EM_PSIZE
+
+ exp $_fork
+ pro $_fork,0
+ loc 2
+ mon
+ zeq *1
+ ste errno
+ loc -1
+ ret EM_WSIZE
+1
+ zeq *2
+ asp EM_WSIZE
+ loc 0
+2
+ ret EM_WSIZE
+ end

+ 16 - 0
lang/cem/libcc/mon/_fstat.e

@@ -0,0 +1,16 @@
+#
+ mes 2,EM_WSIZE,EM_PSIZE
+ exp $_fstat
+ pro $_fstat,0
+ lal 0
+ loi EM_WSIZE+EM_PSIZE
+ loc 28
+ mon
+ zne *1
+ loc 0
+ ret EM_WSIZE
+1
+ ste errno
+ loc -1
+ ret EM_WSIZE
+ end

+ 10 - 0
lang/cem/libcc/mon/_ftime.e

@@ -0,0 +1,10 @@
+#
+ mes 2,EM_WSIZE,EM_PSIZE
+ exp $_ftime
+ pro $_ftime,0
+ lal 0
+ loi EM_PSIZE
+ loc 35
+ mon
+ ret 0
+ end

+ 8 - 0
lang/cem/libcc/mon/_getpid.e

@@ -0,0 +1,8 @@
+#
+ mes 2,EM_WSIZE,EM_PSIZE
+ exp $_getpid
+ pro $_getpid,0
+ loc 20
+ mon
+ ret EM_WSIZE
+ end

+ 6 - 0
lang/cem/libcc/mon/_gtty.c

@@ -0,0 +1,6 @@
+/* $Header$ */
+#include <sgtty.h>
+int
+_gtty(fildes,argp) int fildes ; struct sgttyb *argp ; {
+	return _ioctl(fildes,TIOCGETP,argp) ;
+}

+ 16 - 0
lang/cem/libcc/mon/_ioctl.e

@@ -0,0 +1,16 @@
+#
+ mes 2,EM_WSIZE,EM_PSIZE
+ exp $_ioctl
+ pro $_ioctl,0
+ lal 0
+ loi EM_PSIZE+2*EM_WSIZE
+ loc 54
+ mon
+ zne *1
+ loc 0
+ ret EM_WSIZE
+1
+ ste errno
+ loc -1
+ ret EM_WSIZE
+ end

+ 15 - 0
lang/cem/libcc/mon/_kill.e

@@ -0,0 +1,15 @@
+#
+ mes 2,EM_WSIZE,EM_PSIZE
+ exp $_kill
+ pro $_kill,0
+ ldl 0
+ loc 37
+ mon
+ zne *1
+ loc 0
+ ret EM_WSIZE
+1
+ ste errno
+ loc -1
+ ret EM_WSIZE
+ end

+ 16 - 0
lang/cem/libcc/mon/_link.e

@@ -0,0 +1,16 @@
+#
+ mes 2,EM_WSIZE,EM_PSIZE
+ exp $_link
+ pro $_link,0
+ lal 0
+ loi 2*EM_PSIZE
+ loc 9
+ mon
+ zne *1
+ loc 0
+ ret EM_WSIZE
+1
+ ste errno
+ loc -1
+ ret EM_WSIZE
+ end

+ 33 - 0
lang/cem/libcc/mon/_lseek.e

@@ -0,0 +1,33 @@
+#
+ mes 2,EM_WSIZE,EM_PSIZE
+ exp $_lseek
+ pro $_lseek,0
+ lal 0
+ loi 4*EM_WSIZE
+ loc 19
+ mon
+ zeq *1
+ ste errno
+#if EM_WSIZE==1
+ ldc -1
+ loc 2
+ loc 4
+ cii
+#endif
+#if EM_WSIZE==2
+ ldc -1
+#endif
+#if EM_WSIZE==4
+ loc -1
+#endif
+1
+#if EM_WSIZE==1
+ ret 4*EM_WSIZE
+#endif
+#if EM_WSIZE==2
+ ret 2*EM_WSIZE
+#endif
+#if EM_WSIZE==4
+ ret EM_WSIZE
+#endif
+ end

+ 14 - 0
lang/cem/libcc/mon/_open.e

@@ -0,0 +1,14 @@
+#
+ mes 2,EM_WSIZE,EM_PSIZE
+ exp $_open
+ pro $_open,0
+ lal 0
+ loi EM_WSIZE+EM_PSIZE
+ loc 5
+ mon
+ zeq *1
+ ste errno
+ loc -1
+1
+ ret EM_WSIZE
+ end

+ 8 - 0
lang/cem/libcc/mon/_pause.e

@@ -0,0 +1,8 @@
+#
+ mes 2,EM_WSIZE,EM_PSIZE
+ exp $_pause
+ pro $_pause,0
+ loc 29
+ mon
+ ret 0
+ end

+ 18 - 0
lang/cem/libcc/mon/_pipe.e

@@ -0,0 +1,18 @@
+#
+ mes 2,EM_WSIZE,EM_PSIZE
+ exp $_pipe
+ pro $_pipe,0
+ loc 42
+ mon
+ zeq *1
+ ste errno
+ loc -1
+ ret EM_WSIZE
+1
+ lal 0
+ loi EM_PSIZE
+ stf EM_WSIZE
+ sil 0
+ loc 0
+ ret EM_WSIZE
+ end

+ 23 - 0
lang/cem/libcc/mon/_read.e

@@ -0,0 +1,23 @@
+#
+ mes 2,EM_WSIZE,EM_PSIZE
+ exp $_read
+ pro $_read,0
+ lol EM_WSIZE+EM_PSIZE
+ loc EM_WSIZE
+ loc EM_PSIZE
+ ciu
+ lal 0
+ loi EM_WSIZE+EM_PSIZE
+ loc 3
+ mon
+ zne *1
+ loc EM_PSIZE
+ loc EM_WSIZE
+ cui
+ bra *2
+1
+ ste errno
+ loc -1
+2
+ ret EM_WSIZE
+ end

+ 60 - 0
lang/cem/libcc/mon/_sbrk.e

@@ -0,0 +1,60 @@
+#
+#include <em_abs.h>
+
+ mes 2,EM_WSIZE,EM_PSIZE
+
+.1
+ bss EM_PSIZE,0,0
+.2
+ bss EM_WSIZE,0,0
+
+ pro $ctch,0
+ lol 0
+ loc EHEAP
+ beq *1
+ lae .1
+ loi EM_PSIZE
+ sig
+ asp EM_PSIZE
+ lol 0
+ trp
+ rtt
+1
+ loc 1
+ ste .2
+ rtt
+ end
+
+
+ exp $_sbrk
+ pro $_sbrk,0
+ lor 2
+ lor 2
+ lpi $ctch
+ sig
+ lae .1
+ sti EM_PSIZE
+ loc 0
+ ste .2
+ lol 0
+ ads EM_WSIZE	; this is the new heap pointer, but watch out for overflow!
+ dup EM_PSIZE
+ lor 2
+ cmp		; compare with old heap pointer
+ zlt *1
+ str 2          ; The - possibly - occurring trap is caught
+ lae .1
+ loi EM_PSIZE
+ sig
+ asp EM_PSIZE
+ loe .2
+ zgt *1
+ ret EM_PSIZE
+1
+ asp EM_PSIZE
+ loc -1
+ loc EM_WSIZE
+ loc EM_PSIZE
+ cii
+ ret EM_PSIZE
+ end

+ 16 - 0
lang/cem/libcc/mon/_unlink.e

@@ -0,0 +1,16 @@
+#
+ mes 2,EM_WSIZE,EM_PSIZE
+ exp $_unlink
+ pro $_unlink,0
+ lal 0
+ loi EM_PSIZE
+ loc 10
+ mon
+ zne *1
+ loc 0
+ ret EM_WSIZE
+1
+ ste errno
+ loc -1
+ ret EM_WSIZE
+ end

+ 33 - 0
lang/cem/libcc/mon/_wait.e

@@ -0,0 +1,33 @@
+#
+ mes 2,EM_WSIZE,EM_PSIZE
+#if EM_WSIZE<4
+#define STATUS_SIZE 2
+#else
+#define STATUS_SIZE EM_WSIZE
+#endif
+ exp $_wait
+ pro $_wait,0
+ loc 7
+ mon
+ zne *1
+ lal 0
+ loi EM_PSIZE
+ zer EM_PSIZE
+ cms EM_PSIZE
+ zeq *2
+#if EM_WSIZE==1
+ lal 0
+ loi EM_PSIZE
+ sti 2                  ; 2 bytes, not one int!
+#else
+ sil 0
+#endif
+ ret EM_WSIZE
+2
+ asp STATUS_SIZE
+ ret EM_WSIZE
+1
+ ste errno
+ loc -1
+ ret EM_WSIZE
+ end

+ 23 - 0
lang/cem/libcc/mon/_write.e

@@ -0,0 +1,23 @@
+#
+ mes 2,EM_WSIZE,EM_PSIZE
+ exp $_write
+ pro $_write,0
+ lol EM_WSIZE+EM_PSIZE
+ loc EM_WSIZE
+ loc EM_PSIZE
+ ciu
+ lal 0
+ loi EM_WSIZE+EM_PSIZE
+ loc 4
+ mon
+ zne *1
+ loc EM_PSIZE
+ loc EM_WSIZE
+ cui
+ bra *2
+1
+ ste errno
+ loc -1
+2
+ ret EM_WSIZE
+ end

+ 2 - 1
lang/cem/libcc/mon/gtty.c

@@ -1,5 +1,6 @@
 /* $Header$ */
 #include <sgtty.h>
-int gtty(fildes,argp) int fildes ; struct sgttyb *argp ; {
+int
+gtty(fildes,argp) int fildes ; struct sgttyb *argp ; {
 	return ioctl(fildes,TIOCGETP,argp) ;
 }

+ 2 - 1
lang/cem/libcc/mon/stty.c

@@ -1,5 +1,6 @@
 /* $Header$ */
 #include <sgtty.h>
-int stty(fildes,argp) int fildes ; struct sgttyb *argp ; {
+int
+stty(fildes,argp) int fildes ; struct sgttyb *argp ; {
 	return ioctl(fildes,TIOCSETP,argp) ;
 }

+ 2 - 1
lang/cem/libcc/mon/time.c

@@ -1,7 +1,8 @@
 /* $Header$ */
 #include <sys/types.h>
 #include <sys/timeb.h>
-time_t time(timpt) time_t *timpt ; {
+time_t
+time(timpt) time_t *timpt ; {
 	struct timeb buf ;
 
 	ftime(&buf) ;