├── usr ├── sys │ ├── dmr │ │ ├── mem.c │ │ ├── conf.c │ │ ├── dhfdm.c │ │ ├── partab.c │ │ ├── sys.c │ │ ├── vt.c │ │ ├── cat.c │ │ ├── dn.c │ │ ├── dhdm.c │ │ ├── rf.c │ │ └── vs.c │ ├── conf │ │ ├── data.s │ │ └── low.s │ ├── reg.h │ ├── text.h │ ├── file.h │ ├── seg.h │ ├── ino.h │ ├── filesys.h │ ├── conf.h │ ├── run │ ├── proc.h │ ├── inode.h │ ├── systm.h │ └── ken │ │ └── malloc.c ├── source │ ├── s │ │ ├── s1 │ │ │ ├── init.c │ │ │ ├── getty.c │ │ │ ├── login.c │ │ │ ├── cpall.c │ │ │ ├── exit.c │ │ │ ├── echo.c │ │ │ ├── kill.s │ │ │ ├── chmod.c │ │ │ ├── db4.s │ │ │ ├── ln.c │ │ │ ├── cat.s │ │ │ ├── diff2.s │ │ │ ├── clri.s │ │ │ ├── df.c │ │ │ ├── goto.c │ │ │ ├── cp.c │ │ │ └── form2.s │ │ ├── s2 │ │ │ ├── sh.c │ │ │ ├── typo.c │ │ │ ├── tty.s │ │ │ ├── size.c │ │ │ ├── mknod.c │ │ │ ├── sync.c │ │ │ ├── su.c │ │ │ ├── update.s │ │ │ ├── sleep.c │ │ │ ├── opr.c │ │ │ ├── rew.s │ │ │ ├── nohup.c │ │ │ ├── pfe.s │ │ │ ├── mount.c │ │ │ ├── nice.c │ │ │ ├── tp4.s │ │ │ ├── mkdir.s │ │ │ ├── mesg.c │ │ │ ├── tee.c │ │ │ ├── umount.c │ │ │ ├── wall.c │ │ │ ├── who.c │ │ │ ├── sum.s │ │ │ ├── rm.c │ │ │ └── pwd.c │ │ ├── s4 │ │ │ ├── fork.s │ │ │ ├── getcsw.s │ │ │ ├── getpid.s │ │ │ ├── getuid.s │ │ │ ├── exit.s │ │ │ ├── cerror.s │ │ │ ├── getgid.s │ │ │ ├── close.s │ │ │ ├── execl.s │ │ │ ├── dup.s │ │ │ ├── chdir.s │ │ │ ├── kill.s │ │ │ ├── chmod.s │ │ │ ├── chown.s │ │ │ ├── link.s │ │ │ ├── creat.s │ │ │ ├── fstat.s │ │ │ ├── gtty.s │ │ │ ├── getchr.s │ │ │ ├── execv.s │ │ │ ├── hmul.s │ │ │ ├── abort.s │ │ │ ├── ffltpr.s │ │ │ ├── ldfps.s │ │ │ ├── abs.s │ │ │ ├── crt0.s │ │ │ ├── csv.s │ │ │ ├── fcrt0.s │ │ │ ├── atoi.c │ │ │ ├── ltod.s │ │ │ ├── getc.s │ │ │ ├── ladd.s │ │ │ ├── getpw.c │ │ │ ├── locv.s │ │ │ ├── errlst.c │ │ │ ├── run │ │ │ └── fltpr.s │ │ ├── s5 │ │ │ ├── mon.c │ │ │ ├── wait.s │ │ │ ├── signal.s │ │ │ ├── sleep.s │ │ │ ├── sync.s │ │ │ ├── stime.s │ │ │ ├── times.s │ │ │ ├── nice.s │ │ │ ├── prof.s │ │ │ ├── setuid.s │ │ │ ├── setgid.s │ │ │ ├── makdir.s │ │ │ ├── pipe.s │ │ │ ├── time.s │ │ │ ├── unlink.s │ │ │ ├── umount.s │ │ │ ├── seek.s │ │ │ ├── open.s │ │ │ ├── mount.s │ │ │ ├── write.s │ │ │ ├── mknod.s │ │ │ ├── read.s │ │ │ ├── stat.s │ │ │ ├── stty.s │ │ │ ├── ptrace.s │ │ │ ├── reset.s │ │ │ ├── sbrk.s │ │ │ ├── mcount.s │ │ │ ├── mdate.s │ │ │ ├── nargs.s │ │ │ ├── rin.c │ │ │ ├── perror.c │ │ │ ├── putc.s │ │ │ ├── putchr.s │ │ │ ├── mcrt0.s │ │ │ └── run │ │ ├── solloc │ │ │ ├── run │ │ │ ├── getch.s │ │ │ ├── zero.s │ │ │ ├── bsp.s │ │ │ ├── length.s │ │ │ ├── bword.s │ │ │ ├── rewind.s │ │ │ ├── getwd.s │ │ │ └── altch.s │ │ ├── sno │ │ │ ├── run │ │ │ └── sno.h │ │ ├── s3 │ │ │ ├── savr5.s │ │ │ ├── fakfp.s │ │ │ ├── ttyn.s │ │ │ ├── dpadd.s │ │ │ ├── ldiv.s │ │ │ ├── fmod.s │ │ │ ├── rand.s │ │ │ ├── mesg.s │ │ │ ├── fpx.s │ │ │ ├── floor.s │ │ │ ├── switch.s │ │ │ ├── run │ │ │ ├── pow.s │ │ │ └── sqrt.s │ │ └── s7 │ │ │ ├── run │ │ │ ├── ne5.c │ │ │ └── ne.h │ ├── cref │ │ ├── index │ │ │ ├── econs.h │ │ │ ├── ind2.c │ │ │ └── ecmn.h │ │ ├── mcons.h │ │ ├── index.html │ │ ├── run │ │ ├── src │ │ │ └── put.c │ │ └── ccmn.h │ └── c │ │ └── run └── personal │ ├── kernel │ ├── src │ │ ├── m40.s │ │ ├── sig.c │ │ ├── slp.c │ │ ├── Stack.c │ │ ├── Thread.c │ │ ├── clock.c │ │ ├── main.c │ │ ├── sys1.c │ │ ├── communi │ │ │ ├── Msg.c │ │ │ ├── Event.c │ │ │ ├── Mail.c │ │ │ ├── phymem.c │ │ │ ├── Semaphore.c │ │ │ └── SharedMem.c │ │ └── text.c │ └── include │ │ ├── comm.h │ │ ├── proc.h │ │ ├── Thread.h │ │ └── Thread_U.h │ └── user │ ├── src │ ├── CreatThd.s │ ├── ThdEntry.c │ ├── gettid.s │ ├── communi │ │ ├── CreatSharedMbx.s │ │ ├── CloseMbx.s │ │ ├── SetEvt.s │ │ ├── CloseEvt.s │ │ ├── CreatEvt.s │ │ ├── CreatSem.s │ │ ├── CloseSem.s │ │ ├── AcqSem.s │ │ ├── RelSem.s │ │ ├── FreeSharedMem.s │ │ ├── UnmapSharedMem.s │ │ ├── CreatPrivMbx.s │ │ ├── ClosePubMbx.s │ │ ├── WaitEvt.s │ │ ├── CreatePubMbx.s │ │ ├── MapSharedMem.s │ │ ├── RcvMsg.s │ │ ├── Mutex.c │ │ ├── RcvMail.s │ │ ├── SendMail.s │ │ ├── SendMsg.s │ │ ├── RcvPubMail.s │ │ ├── SendSharedMail.s │ │ └── CreatSharedMem.s │ ├── ExitThd.s │ ├── SuspThd.s │ ├── ResumThd.s │ ├── GetThdID.s │ ├── GetThdName.s │ └── TermThd.s │ └── include │ ├── Thread.h │ ├── param.h │ └── comm.h └── README.md /usr/sys/dmr/mem.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/sys/dmr/mem.c -------------------------------------------------------------------------------- /usr/sys/dmr/conf.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/sys/dmr/conf.c -------------------------------------------------------------------------------- /usr/source/s/s1/init.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/source/s/s1/init.c -------------------------------------------------------------------------------- /usr/source/s/s2/sh.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/source/s/s2/sh.c -------------------------------------------------------------------------------- /usr/source/s/s2/typo.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/source/s/s2/typo.c -------------------------------------------------------------------------------- /usr/source/s/s4/fork.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/source/s/s4/fork.s -------------------------------------------------------------------------------- /usr/source/s/s5/mon.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/source/s/s5/mon.c -------------------------------------------------------------------------------- /usr/source/s/s5/wait.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/source/s/s5/wait.s -------------------------------------------------------------------------------- /usr/source/s/s1/getty.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/source/s/s1/getty.c -------------------------------------------------------------------------------- /usr/source/s/s1/login.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/source/s/s1/login.c -------------------------------------------------------------------------------- /usr/source/s/s5/signal.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/source/s/s5/signal.s -------------------------------------------------------------------------------- /usr/personal/kernel/src/m40.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/personal/kernel/src/m40.s -------------------------------------------------------------------------------- /usr/personal/kernel/src/sig.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/personal/kernel/src/sig.c -------------------------------------------------------------------------------- /usr/personal/kernel/src/slp.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/personal/kernel/src/slp.c -------------------------------------------------------------------------------- /usr/sys/conf/data.s: -------------------------------------------------------------------------------- 1 | / l45.o needs to be in data space 2 | / to get l45.o; as data.s l.s 3 | .data 4 | -------------------------------------------------------------------------------- /usr/personal/kernel/src/Stack.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/personal/kernel/src/Stack.c -------------------------------------------------------------------------------- /usr/personal/kernel/src/Thread.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/personal/kernel/src/Thread.c -------------------------------------------------------------------------------- /usr/personal/kernel/src/clock.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/personal/kernel/src/clock.c -------------------------------------------------------------------------------- /usr/personal/kernel/src/main.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/personal/kernel/src/main.c -------------------------------------------------------------------------------- /usr/personal/kernel/src/sys1.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/personal/kernel/src/sys1.c -------------------------------------------------------------------------------- /usr/personal/user/src/CreatThd.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/personal/user/src/CreatThd.s -------------------------------------------------------------------------------- /usr/personal/user/src/ThdEntry.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/personal/user/src/ThdEntry.c -------------------------------------------------------------------------------- /usr/personal/kernel/include/comm.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/personal/kernel/include/comm.h -------------------------------------------------------------------------------- /usr/personal/kernel/include/proc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/personal/kernel/include/proc.h -------------------------------------------------------------------------------- /usr/personal/user/include/Thread.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/personal/user/include/Thread.h -------------------------------------------------------------------------------- /usr/personal/user/include/param.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/personal/user/include/param.h -------------------------------------------------------------------------------- /usr/personal/kernel/include/Thread.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/personal/kernel/include/Thread.h -------------------------------------------------------------------------------- /usr/personal/kernel/src/communi/Msg.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/personal/kernel/src/communi/Msg.c -------------------------------------------------------------------------------- /usr/personal/kernel/include/Thread_U.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/personal/kernel/include/Thread_U.h -------------------------------------------------------------------------------- /usr/personal/kernel/src/communi/Event.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/personal/kernel/src/communi/Event.c -------------------------------------------------------------------------------- /usr/personal/kernel/src/communi/Mail.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/personal/kernel/src/communi/Mail.c -------------------------------------------------------------------------------- /usr/personal/kernel/src/communi/phymem.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/personal/kernel/src/communi/phymem.c -------------------------------------------------------------------------------- /usr/personal/kernel/src/communi/Semaphore.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/personal/kernel/src/communi/Semaphore.c -------------------------------------------------------------------------------- /usr/personal/kernel/src/communi/SharedMem.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JiYou/unix-v6/HEAD/usr/personal/kernel/src/communi/SharedMem.c -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # unix-v6 2 | 3 | 《返璞归真:UNIX技术内幕》一书配套代码。 4 | 5 | # 联系方式 6 | 7 | 作者博客:http://blog.chinaunix.net/uid/23741326/abstract/1.html 8 | 9 | -------------------------------------------------------------------------------- /usr/source/s/s5/sleep.s: -------------------------------------------------------------------------------- 1 | .globl _sleep 2 | sleep = 35. 3 | 4 | _sleep: 5 | mov r5,-(sp) 6 | mov sp,r5 7 | mov 4(r5),r0 8 | sys sleep 9 | mov (sp)+,r5 10 | rts pc 11 | -------------------------------------------------------------------------------- /usr/source/s/s5/sync.s: -------------------------------------------------------------------------------- 1 | .globl _sync 2 | sync = 36. 3 | 4 | _sync: 5 | mov r5,-(sp) 6 | mov sp,r5 7 | sys sync 8 | mov (sp)+,r5 9 | rts pc 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /usr/source/s/s4/getcsw.s: -------------------------------------------------------------------------------- 1 | / C library - getcsw 2 | 3 | / csw = getcsw(); 4 | 5 | .globl _getcsw 6 | 7 | _getcsw: 8 | mov r5,-(sp) 9 | mov sp,r5 10 | sys 38. 11 | mov (sp)+,r5 12 | rts pc 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /usr/personal/user/src/gettid.s: -------------------------------------------------------------------------------- 1 | #define GETTID 75 2 | #int gettid() 3 | #{ 4 | .globl _gettid 5 | _gettid: 6 | mov r5,-(sp) 7 | mov sp,r5 8 | sys GETTID 9 | bec 1f 10 | jmp cerror 11 | 1: 12 | mov (sp)+,r5 13 | rts pc 14 | #} 15 | 16 | -------------------------------------------------------------------------------- /usr/personal/user/src/communi/CreatSharedMbx.s: -------------------------------------------------------------------------------- 1 | #int CreateSharedMbx() 2 | #{ 3 | .globl _CreateSharedMbx 4 | _CreateSharedMbx: 5 | mov r5,-(sp) 6 | mov sp,r5 7 | sys 64 8 | bec 1f 9 | jmp cerror 10 | 1: 11 | mov (sp)+,r5 12 | rts pc 13 | #} 14 | -------------------------------------------------------------------------------- /usr/source/s/s4/getpid.s: -------------------------------------------------------------------------------- 1 | / getpid -- get process ID 2 | 3 | getpid = 20. 4 | 5 | .globl _getpid 6 | 7 | _getpid: 8 | mov r5,-(sp) 9 | mov sp,r5 10 | sys getpid 11 | mov (sp)+,r5 12 | rts pc 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /usr/source/s/s5/stime.s: -------------------------------------------------------------------------------- 1 | .globl _stime, cerror 2 | 3 | _stime: 4 | mov r5,-(sp) 5 | mov sp,r5 6 | mov 4(sp),r1 7 | mov (r1)+,r0 8 | mov (r1),r1 9 | sys stime 10 | bec 1f //carrir == 0? 11 | jmp cerror 12 | 1: 13 | clr r0 14 | mov (sp)+,r5 15 | rts pc 16 | 17 | -------------------------------------------------------------------------------- /usr/personal/user/src/communi/CloseMbx.s: -------------------------------------------------------------------------------- 1 | #int CloseMbx(int md) 2 | #{ 3 | .globl _CloseMbx 4 | _CloseMbx: 5 | mov r5,-(sp) 6 | mov sp,r5 7 | mov 4(r5),r0 8 | sys 61 9 | bec 1f 10 | jmp cerror 11 | 1: 12 | clr r0 13 | mov (sp)+,r5 14 | rts pc 15 | #} 16 | -------------------------------------------------------------------------------- /usr/personal/user/src/communi/SetEvt.s: -------------------------------------------------------------------------------- 1 | #int SetEvent(int ed) 2 | #{ 3 | .globl _SetEvent 4 | _SetEvent: 5 | mov r5,-(sp) 6 | mov sp,r5 7 | mov 4(r5),r0 8 | sys 57 9 | bec 1f 10 | jmp cerror 11 | 1: 12 | clr r0 13 | mov (sp)+,r5 14 | rts pc 15 | #} 16 | -------------------------------------------------------------------------------- /usr/source/s/s4/getuid.s: -------------------------------------------------------------------------------- 1 | / C library -- getuid 2 | 3 | / uid = getuid(); 4 | / 5 | 6 | .globl _getuid 7 | 8 | _getuid: 9 | mov r5,-(sp) 10 | mov sp,r5 11 | sys getuid 12 | mov (sp)+,r5 13 | rts pc 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /usr/personal/user/src/ExitThd.s: -------------------------------------------------------------------------------- 1 | #define EXITTHD 74 2 | #int ExitThread(int exitCode) 3 | #{ 4 | .globl _ExitThread 5 | _ExitThread: 6 | mov r5,-(sp) 7 | mov sp,r5 8 | mov 4(r5),r0 9 | sys EXITTHD 10 | jmp cerror 11 | mov (sp)+,r5 12 | rts pc 13 | #} 14 | -------------------------------------------------------------------------------- /usr/personal/user/src/communi/CloseEvt.s: -------------------------------------------------------------------------------- 1 | #int CloseEvent(int ed) 2 | #{ 3 | .globl _CloseEvent 4 | _CloseEvent: 5 | mov r5,-(sp) 6 | mov sp,r5 7 | mov 4(r5),r0 8 | sys 55 9 | bec 1f 10 | jmp cerror 11 | 1: 12 | clr r0 13 | mov (sp)+,r5 14 | rts pc 15 | #} 16 | -------------------------------------------------------------------------------- /usr/personal/user/src/communi/CreatEvt.s: -------------------------------------------------------------------------------- 1 | #int CreateEvent(BOOL initStatus) 2 | #{ 3 | .globl _CreateEvent 4 | _CreateEvent: 5 | mov r5,-(sp) 6 | mov sp,r5 7 | mov 4(r5),r0 8 | sys 54 9 | bec 1f 10 | jmp cerror 11 | 1: 12 | mov (sp)+,r5 13 | rts pc 14 | #} 15 | -------------------------------------------------------------------------------- /usr/source/s/s4/exit.s: -------------------------------------------------------------------------------- 1 | / C library -- exit 2 | 3 | / exit(code) 4 | / code is return in r0 to system 5 | 6 | .globl _exit 7 | 8 | _exit: 9 | mov r5,-(sp) 10 | mov sp,r5 11 | mov 4(r5),r0 12 | sys exit 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /usr/personal/user/src/communi/CreatSem.s: -------------------------------------------------------------------------------- 1 | #int CreateSemphore(int initNum) 2 | #{ 3 | .globl _CreateSemphore 4 | _CreateSemphore: 5 | mov r5,-(sp) 6 | mov sp,r5 7 | mov 4(r5),r0 8 | sys 50 9 | bec 1f 10 | jmp cerror 11 | 1: 12 | mov (sp)+,r5 13 | rts pc 14 | #} 15 | -------------------------------------------------------------------------------- /usr/personal/user/src/communi/CloseSem.s: -------------------------------------------------------------------------------- 1 | #int CloseSemphore(int sd) 2 | #{ 3 | .globl _CloseSemphore 4 | _CloseSemphore: 5 | mov r5,-(sp) 6 | mov sp,r5 7 | mov 4(r5),r0 8 | sys 51 9 | bec 1f 10 | jmp cerror 11 | 1: 12 | clr r0 13 | mov (sp)+,r5 14 | rts pc 15 | #} 16 | -------------------------------------------------------------------------------- /usr/source/s/s4/cerror.s: -------------------------------------------------------------------------------- 1 | / C return sequence which 2 | / sets errno, returns -1. 3 | 4 | .globl cerror 5 | .comm _errno,2 6 | 7 | cerror: 8 | mov r0,_errno 9 | mov $-1,r0 10 | mov r5,sp 11 | mov (sp)+,r5 12 | rts pc 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /usr/source/s/s4/getgid.s: -------------------------------------------------------------------------------- 1 | / C library -- getgid 2 | 3 | / gid = getgid(); 4 | / 5 | 6 | getgid = 47. 7 | .globl _getgid 8 | 9 | _getgid: 10 | mov r5,-(sp) 11 | mov sp,r5 12 | sys getgid 13 | mov (sp)+,r5 14 | rts pc 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /usr/personal/user/src/communi/AcqSem.s: -------------------------------------------------------------------------------- 1 | #int AcquireSemphore (int sd) 2 | #{ 3 | .globl _AcquireSemphore 4 | _AcquireSemphore: 5 | mov r5,-(sp) 6 | mov sp,r5 7 | mov 4(r5),r0 8 | sys 52 9 | bec 1f 10 | jmp cerror 11 | 1: 12 | clr r0 13 | mov (sp)+,r5 14 | rts pc 15 | #} 16 | -------------------------------------------------------------------------------- /usr/personal/user/src/communi/RelSem.s: -------------------------------------------------------------------------------- 1 | #int ReleaseSemphore(int sd) 2 | #{ 3 | .globl _ReleaseSemphore 4 | _ReleaseSemphore: 5 | mov r5,-(sp) 6 | mov sp,r5 7 | mov 4(r5),r0 8 | sys 53 9 | bec 1f 10 | jmp cerror 11 | 1: 12 | clr r0 13 | mov (sp)+,r5 14 | rts pc 15 | #} 16 | -------------------------------------------------------------------------------- /usr/personal/user/src/SuspThd.s: -------------------------------------------------------------------------------- 1 | #define SUSPTHREAD 76 2 | #int SuspendThread(int tid) 3 | #{ 4 | .globl _SuspendThread 5 | _SuspendThread: 6 | mov r5,-(sp) 7 | mov sp,r5 8 | mov 4(r5),r0 9 | sys SUSPTHREAD 10 | jmp cerror 11 | clr r0 12 | mov (sp)+,r5 13 | rts pc 14 | #} 15 | -------------------------------------------------------------------------------- /usr/personal/user/src/communi/FreeSharedMem.s: -------------------------------------------------------------------------------- 1 | #int FreeSharedMemory(int shd) 2 | #{ 3 | .globl _FreeSharedMemory 4 | _FreeSharedMemory: 5 | mov r5,-(sp) 6 | mov sp,r5 7 | mov 4(r5),r0 8 | sys 70 9 | bec 1f 10 | jmp cerror 11 | 1: 12 | clr r0 13 | mov (sp)+,r5 14 | rts pc 15 | #} 16 | -------------------------------------------------------------------------------- /usr/personal/user/src/ResumThd.s: -------------------------------------------------------------------------------- 1 | #define RESUMTHREAD 77 2 | 3 | #int ResumeThread(int tid) 4 | #{ 5 | .globl _ResumeThread 6 | _ResumeThread: 7 | mov r5,-(sp) 8 | mov sp,r5 9 | mov 4(r5),r0 10 | sys RESUMTHREAD 11 | jmp cerror 12 | clr r0 13 | mov (sp)+,r5 14 | rts pc 15 | #} 16 | -------------------------------------------------------------------------------- /usr/personal/user/src/communi/UnmapSharedMem.s: -------------------------------------------------------------------------------- 1 | #int UnmapSharedMemory(int shd) 2 | #{ 3 | .globl _UnmapSharedMemory 4 | _UnmapSharedMemory: 5 | mov r5,-(sp) 6 | mov sp,r5 7 | mov 4(r5),r0 8 | sys 72 9 | bec 1f 10 | jmp cerror 11 | 1: 12 | clr r0 13 | mov (sp)+,r5 14 | rts pc 15 | #} 16 | -------------------------------------------------------------------------------- /usr/source/s/s5/times.s: -------------------------------------------------------------------------------- 1 | / C library -- times 2 | 3 | .globl _times 4 | times = 43. 5 | 6 | _times: 7 | mov r5,-(sp) 8 | mov sp,r5 9 | mov 4(r5),0f 10 | sys 0; 9f 11 | mov (sp)+,r5 12 | rts pc 13 | .data 14 | 9: 15 | sys times; 0:.. 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /usr/personal/user/src/communi/CreatPrivMbx.s: -------------------------------------------------------------------------------- 1 | #int CreatePrivMbx(char *name) 2 | #{ 3 | .globl _CreatePrivMbx 4 | _CreatePrivMbx: 5 | mov r5,-(sp) 6 | mov sp,r5 7 | mov 4(r5),0f 8 | sys 0; 9f 9 | bec 1f 10 | jmp cerror 11 | 1: 12 | mov (sp)+,r5 13 | rts pc 14 | 9: 15 | sys 60; 0: .. 16 | #} 17 | -------------------------------------------------------------------------------- /usr/sys/dmr/dhfdm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * DM-BB fake driver 3 | */ 4 | #include "../tty.h" 5 | #include "../conf.h" 6 | 7 | struct tty dh11[]; 8 | 9 | dmopen(dev) 10 | { 11 | register struct tty *tp; 12 | 13 | tp = &dh11[dev.d_minor]; 14 | tp->t_state =| CARR_ON; 15 | } 16 | 17 | dmclose(dev) 18 | { 19 | } -------------------------------------------------------------------------------- /usr/source/s/s2/tty.s: -------------------------------------------------------------------------------- 1 | / tty -- get tty number 2 | 3 | .globl ttyn 4 | 5 | clr r0 6 | jsr pc,ttyn 7 | movb r0,nam 8 | mov $1,r0 9 | sys write; name; 5 10 | sys exit 11 | 12 | .data 13 | name: 14 | <tty> 15 | nam: 16 | <x\n> 17 | .even 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /usr/personal/user/src/communi/ClosePubMbx.s: -------------------------------------------------------------------------------- 1 | #int ClosePublicMbx(char *name) 2 | #{ 3 | .globl _ClosePublicMbx 4 | _ClosePublicMbx: 5 | mov r5,-(sp) 6 | mov sp,r5 7 | mov 4(r5),0f 8 | sys 0; 9f 9 | bec 1f 10 | jmp cerror 11 | 1: 12 | clr r0 13 | mov (sp)+,r5 14 | rts pc 15 | 9: 16 | sys 67; 0: .. 17 | #} 18 | -------------------------------------------------------------------------------- /usr/personal/user/src/communi/WaitEvt.s: -------------------------------------------------------------------------------- 1 | #int WaitEvent(int ed, time) 2 | #{ 3 | .globl _WaitEvent 4 | _WaitEvent: 5 | mov r5,-(sp) 6 | mov sp,r5 7 | mov 4(r5),r0 8 | mov 6(r5),0f 9 | sys 0; 9f 10 | bec 1f 11 | jmp cerror 12 | 1: 13 | mov (sp)+,r5 14 | rts pc 15 | .data 16 | 9: 17 | sys 56; 0: .. 18 | #} 19 | -------------------------------------------------------------------------------- /usr/personal/user/src/communi/CreatePubMbx.s: -------------------------------------------------------------------------------- 1 | #int CreatePublicMbx(char *name) 2 | #{ 3 | .globl _CreatePublicMbx 4 | _CreatePublicMbx: 5 | mov r5,-(sp) 6 | mov sp,r5 7 | mov 4(r5),0f 8 | sys 0; 9f 9 | bec 1f 10 | jmp cerror 11 | 1: 12 | clr r0 13 | mov (sp)+,r5 14 | rts pc 15 | 9: 16 | sys 66; 0: .. 17 | #} 18 | -------------------------------------------------------------------------------- /usr/source/s/s5/nice.s: -------------------------------------------------------------------------------- 1 | / C library-- nice 2 | 3 | / error = nice(hownice) 4 | 5 | .globl _nice, cerror 6 | 7 | _nice: 8 | mov r5,-(sp) 9 | mov sp,r5 10 | mov 4(sp),r0 11 | sys nice 12 | bec 1f 13 | jmp cerror 14 | 1: 15 | clr r0 16 | mov (sp)+,r5 17 | rts pc 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /usr/personal/user/src/GetThdID.s: -------------------------------------------------------------------------------- 1 | #define GETTHDID 79 2 | #int GetThreadID(char *name) 3 | #{ 4 | .globl _GetThreadID 5 | _GetThreadID: 6 | mov r5,-(sp) 7 | mov sp,r5 8 | mov 4(r5), 0f 9 | sys 0; 9f 10 | bec 1f 11 | jmp cerror 12 | 1: 13 | mov (sp)+,r5 14 | rts pc 15 | 9: 16 | sys GETTHDID; 0:..; 17 | #} 18 | -------------------------------------------------------------------------------- /usr/source/s/s4/close.s: -------------------------------------------------------------------------------- 1 | / C library -- close 2 | 3 | / error = close(file); 4 | 5 | .globl _close, cerror 6 | 7 | _close: 8 | mov r5,-(sp) 9 | mov sp,r5 10 | mov 4(r5),r0 11 | sys close 12 | bec 1f 13 | jmp cerror 14 | 1: 15 | clr r0 16 | mov (sp)+,r5 17 | rts pc 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /usr/source/s/s4/execl.s: -------------------------------------------------------------------------------- 1 | / C library -- execl 2 | 3 | / execl(file, arg1, arg2, ... , 0); 4 | / 5 | 6 | .globl _execl, cerror 7 | 8 | _execl: 9 | mov r5,-(sp) 10 | mov sp,r5 11 | mov 4(r5),0f 12 | mov r5,r0 13 | add $6,r0 14 | mov r0,0f+2 15 | sys 0; 9f 16 | jmp cerror 17 | .data 18 | 9: 19 | sys exec; 0:..; .. 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /usr/source/s/s5/prof.s: -------------------------------------------------------------------------------- 1 | / profil 2 | 3 | .globl _profil 4 | _profil: 5 | mov r5,-(sp) 6 | mov sp,r5 7 | mov 4(r5),0f 8 | mov 6(r5),0f+2 9 | mov 10(r5),0f+4 10 | mov 12(r5),0f+6 11 | sys 0; 9f 12 | mov (sp)+,r5 13 | rts pc 14 | .data 15 | 9: 16 | sys 44.; 0:..; ..; ..; .. 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /usr/source/s/s5/setuid.s: -------------------------------------------------------------------------------- 1 | 2 | / C library -- setuid 3 | 4 | / error = setuid(uid); 5 | 6 | .globl _setuid, cerror 7 | 8 | _setuid: 9 | mov r5,-(sp) 10 | mov sp,r5 11 | mov 4(r5),r0 12 | sys setuid 13 | bec 1f 14 | jmp cerror 15 | 1: 16 | clr r0 17 | mov (sp)+,r5 18 | rts pc 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /usr/personal/user/src/communi/MapSharedMem.s: -------------------------------------------------------------------------------- 1 | #int MapSharedMemory(char *name, MapShm *ms) 2 | #{ 3 | .globl _MapSharedMemory 4 | _MapSharedMemory: 5 | mov r5,-(sp) 6 | mov sp,r5 7 | mov 4(r5),0f 8 | mov 6(r5),0f+2 9 | sys 0; 9f 10 | bec 1f 11 | jmp cerror 12 | 1: 13 | mov (sp)+,r5 14 | rts pc 15 | 9: 16 | sys 71; 0: ..;.. 17 | #} 18 | -------------------------------------------------------------------------------- /usr/source/s/s4/dup.s: -------------------------------------------------------------------------------- 1 | / C library -- dup 2 | 3 | / f = dup(of) 4 | / f == -1 for error 5 | 6 | dup = 41. 7 | 8 | .globl _dup, cerror 9 | 10 | _dup: 11 | mov r5,-(sp) 12 | mov sp,r5 13 | mov 4(r5),r0 14 | sys dup 15 | bec 1f 16 | jmp cerror 17 | 1: 18 | mov (sp)+,r5 19 | rts pc 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /usr/source/s/s5/setgid.s: -------------------------------------------------------------------------------- 1 | / C library -- setgid 2 | 3 | / error = setgid(uid); 4 | 5 | setgid = 46. 6 | .globl _setgid, cerror 7 | 8 | _setgid: 9 | mov r5,-(sp) 10 | mov sp,r5 11 | mov 4(r5),r0 12 | sys setgid 13 | bec 1f 14 | jmp cerror 15 | 1: 16 | clr r0 17 | mov (sp)+,r5 18 | rts pc 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /usr/sys/reg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Location of the users' stored 3 | * registers relative to R0. 4 | * Usage is u.u_ar0[XX]. 5 | */ 6 | #define R0 (0) 7 | #define R1 (-2) 8 | #define R2 (-9) 9 | #define R3 (-8) 10 | #define R4 (-7) 11 | #define R5 (-6) 12 | #define R6 (-3) 13 | #define R7 (1) 14 | #define RPS (2) 15 | 16 | #define TBIT 020 /* PS trace bit */ -------------------------------------------------------------------------------- /usr/source/s/s4/chdir.s: -------------------------------------------------------------------------------- 1 | / C library -- chdir 2 | 3 | / error = chdir(string); 4 | 5 | .globl _chdir, cerror 6 | 7 | _chdir: 8 | mov r5,-(sp) 9 | mov sp,r5 10 | mov 4(r5),0f 11 | sys 0; 9f 12 | bec 1f 13 | jmp cerror 14 | 1: 15 | clr r0 16 | mov (sp)+,r5 17 | rts pc 18 | .data 19 | 9: 20 | sys chdir; 0:.. 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /usr/source/s/solloc/run: -------------------------------------------------------------------------------- 1 | as alloc.s; mv a.out alloc.o 2 | as altch.s; mv a.out altch.o 3 | as bsp.s; mv a.out bsp.o 4 | as bword.s; mv a.out bword.o 5 | as getch.s; mv a.out getch.o 6 | as getwd.s; mv a.out getwd.o 7 | as length.s; mv a.out length.o 8 | as rewind.s; mv a.out rewind.o 9 | as zero.s; mv a.out zero.o 10 | ar r /lib/libs.a *.o 11 | rm *.o 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /usr/personal/user/src/communi/RcvMsg.s: -------------------------------------------------------------------------------- 1 | #int ReceiveMessage(char *msg, int len, int time) 2 | #{ 3 | .globl _ReceiveMessage 4 | _ReceiveMessage: 5 | mov r5,-(sp) 6 | mov sp,r5 7 | mov 4(r5),0f 8 | mov 6(r5),0f+2 9 | mov 8(r5),0f+4 10 | sys 0; 9f 11 | bec 1f 12 | jmp cerror 13 | 1: 14 | mov (sp)+,r5 15 | rts pc 16 | .data 17 | 9: 18 | sys 59; 0: ..;..;.. 19 | #} 20 | -------------------------------------------------------------------------------- /usr/source/s/s5/makdir.s: -------------------------------------------------------------------------------- 1 | / C library -- makdir 2 | 3 | / error = makdir(string); 4 | 5 | .globl _makdir, cerror 6 | 7 | _makdir: 8 | mov r5,-(sp) 9 | mov sp,r5 10 | mov 4(r5),0f 11 | sys 0; 9f 12 | bec 1f 13 | jmp cerror 14 | 1: 15 | clr r0 16 | mov (sp)+,r5 17 | rts pc 18 | .data 19 | 9: 20 | sys makdir; 0:.. 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /usr/source/s/s5/pipe.s: -------------------------------------------------------------------------------- 1 | / pipe -- C library 2 | 3 | / pipe(f) 4 | / int f[2]; 5 | 6 | .globl _pipe, cerror 7 | 8 | pipe = 42. 9 | 10 | _pipe: 11 | mov r5,-(sp) 12 | mov sp,r5 13 | sys pipe 14 | bec 1f 15 | jmp cerror 16 | 1: 17 | mov 4(r5),r2 18 | mov r0,(r2)+ 19 | mov r1,(r2) 20 | clr r0 21 | mov (sp)+,r5 22 | rts pc 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /usr/source/s/s5/time.s: -------------------------------------------------------------------------------- 1 | / C library -- time 2 | 3 | / tvec = time(tvec); 4 | / 5 | / tvec[0], tvec[1] contain the time 6 | 7 | .globl _time 8 | 9 | _time: 10 | mov r5,-(sp) 11 | mov sp,r5 12 | sys time 13 | mov r2,-(sp) 14 | mov 4(r5),r2 15 | mov r0,(r2)+ 16 | mov r1,(r2)+ 17 | mov (sp)+,r2 18 | mov (sp)+,r5 19 | rts pc 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /usr/source/s/s5/unlink.s: -------------------------------------------------------------------------------- 1 | / C library -- unlink 2 | 3 | / error = unlink(string); 4 | / 5 | 6 | .globl _unlink, cerror 7 | 8 | _unlink: 9 | mov r5,-(sp) 10 | mov sp,r5 11 | mov 4(r5),0f 12 | sys 0; 9f 13 | bec 1f 14 | jmp cerror 15 | 1: 16 | clr r0 17 | mov (sp)+,r5 18 | rts pc 19 | .data 20 | 9: 21 | sys unlink; 0:.. 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /usr/source/s/s4/kill.s: -------------------------------------------------------------------------------- 1 | / C library -- kill 2 | 3 | .globl _kill, cerror 4 | kill = 37. 5 | indir = 0 6 | 7 | _kill: 8 | mov r5,-(sp) 9 | mov sp,r5 10 | mov 4(sp),r0 11 | mov 6(sp),8f 12 | sys indir; 9f 13 | bec 1f 14 | jmp cerror 15 | 1: 16 | clr r0 17 | mov (sp)+,r5 18 | rts pc 19 | 20 | .data 21 | 9: 22 | sys kill; 8:.. 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /usr/personal/user/src/GetThdName.s: -------------------------------------------------------------------------------- 1 | #define GETTHDNAME 80 2 | #int GetThreadName(int tid, char name[12]) 3 | #{ 4 | .globl _GetThreadName 5 | _GetThreadName: 6 | mov r5,-(sp) 7 | mov sp,r5 8 | mov 4(r5), 0f 9 | mov 6(r5), 0f+2 10 | sys 0; 9f 11 | bec 1f 12 | jmp cerror 13 | 1: 14 | clr r0 15 | mov (sp)+,r5 16 | rts pc 17 | 9: 18 | sys GETTHDNAME; 0:..;.. 19 | #} 20 | -------------------------------------------------------------------------------- /usr/personal/user/src/communi/Mutex.c: -------------------------------------------------------------------------------- 1 | #include "../../include/comm.h" 2 | int CreateMutex() 3 | { 4 | return CreateSemphore(1); 5 | } 6 | 7 | int CloseMutex(int md) 8 | { 9 | return CloseSemphore(md); 10 | } 11 | 12 | int AcquireMutex(int md) 13 | { 14 | return AcquireSemphore(md); 15 | } 16 | 17 | int ReleaseMutex(int md) 18 | { 19 | return ReleaseSemphore(md); 20 | } 21 | 22 | 23 | -------------------------------------------------------------------------------- /usr/source/s/s5/umount.s: -------------------------------------------------------------------------------- 1 | / C library -- umount/ 2 | 3 | .globl _umount 4 | .globl cerror 5 | indir = 0 6 | .comm _errno,2 7 | 8 | _umount: 9 | mov r5,-(sp) 10 | mov sp,r5 11 | mov 4(sp),0f 12 | sys indir; 9f 13 | bec 1f 14 | jmp cerror 15 | 1: 16 | clr r0 17 | mov (sp)+,r5 18 | rts pc 19 | 20 | .data 21 | 9: 22 | sys umount; 0:.. 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /usr/personal/user/src/communi/RcvMail.s: -------------------------------------------------------------------------------- 1 | #int ReceiveMail(int mbxd, char *mail, int len, int time) 2 | #{ 3 | .globl _ReceiveMail 4 | _ReceiveMail: 5 | mov r5,-(sp) 6 | mov sp,r5 7 | mov 4(r5), r0 8 | mov 6(r5),0f 9 | mov 8(r5),0f+2 10 | mov 10(r5),0f+4 11 | sys 0; 9f 12 | bec 1f 13 | jmp cerror 14 | 1: 15 | mov (sp)+,r5 16 | rts pc 17 | .data 18 | 9: 19 | sys 63; 0: ..;..;.. 20 | #} 21 | -------------------------------------------------------------------------------- /usr/personal/user/src/communi/SendMail.s: -------------------------------------------------------------------------------- 1 | #int SendMail(char *name, char *mail, int len, int time) 2 | #{ 3 | .globl _SendMail 4 | _SendMail: 5 | mov r5,-(sp) 6 | mov sp,r5 7 | mov 4(r5), 0f 8 | mov 6(r5),0f+2 9 | mov 8(r5),0f+4 10 | mov 10(r5),0f+6 11 | sys 0; 9f 12 | bec 1f 13 | jmp cerror 14 | 1: 15 | mov (sp)+,r5 16 | rts pc 17 | .data 18 | 9: 19 | sys 62; 0: ..;..;..;.. 20 | #} 21 | -------------------------------------------------------------------------------- /usr/personal/user/src/communi/SendMsg.s: -------------------------------------------------------------------------------- 1 | #int SendMessage(int pid, char *msg, int len, int time) 2 | #{ 3 | .globl _SendMessage 4 | _SendMessage: 5 | mov r5,-(sp) 6 | mov sp,r5 7 | mov 4(r5), r0 8 | mov 6(r5),0f 9 | mov 8(r5),0f+2 10 | mov 10(r5),0f+4 11 | sys 0; 9f 12 | bec 1f 13 | jmp cerror 14 | 1: 15 | mov (sp)+,r5 16 | rts pc 17 | .data 18 | 9: 19 | sys 58; 0: ..;..;.. 20 | #} 21 | -------------------------------------------------------------------------------- /usr/source/s/s4/chmod.s: -------------------------------------------------------------------------------- 1 | / C library -- chmod 2 | 3 | / error = chmod(string, mode); 4 | 5 | .globl _chmod, cerror 6 | 7 | _chmod: 8 | mov r5,-(sp) 9 | mov sp,r5 10 | mov 4(r5),0f 11 | mov 6(r5),0f+2 12 | sys 0; 9f 13 | bec 1f 14 | jmp cerror 15 | 1: 16 | clr r0 17 | mov (sp)+,r5 18 | rts pc 19 | .data 20 | 9: 21 | sys chmod; 0:..; .. 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /usr/source/s/s4/chown.s: -------------------------------------------------------------------------------- 1 | / C library -- chown 2 | 3 | / error = chown(string, owner); 4 | 5 | .globl _chown, cerror 6 | 7 | _chown: 8 | mov r5,-(sp) 9 | mov sp,r5 10 | mov 4(r5),0f 11 | mov 6(r5),0f+2 12 | sys 0; 9f 13 | bec 1f 14 | jmp cerror 15 | 1: 16 | clr r0 17 | mov (sp)+,r5 18 | rts pc 19 | .data 20 | 9: 21 | sys chown; 0:..; .. 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /usr/source/s/s4/link.s: -------------------------------------------------------------------------------- 1 | / C library -- link 2 | 3 | / error = link(old-file, new-file); 4 | / 5 | 6 | .globl _link, cerror 7 | 8 | _link: 9 | mov r5,-(sp) 10 | mov sp,r5 11 | mov 4(r5),0f 12 | mov 6(r5),0f+2 13 | sys 0; 9f 14 | bec 1f 15 | jmp cerror 16 | 1: 17 | clr r0 18 | mov (sp)+,r5 19 | rts pc 20 | .data 21 | 9: 22 | sys link; 0:..; .. 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /usr/source/s/s5/seek.s: -------------------------------------------------------------------------------- 1 | / C library -- seek 2 | 3 | / error = seek(file, offset, ptr); 4 | 5 | .globl _seek, cerror 6 | 7 | _seek: 8 | mov r5,-(sp) 9 | mov sp,r5 10 | mov 4(r5),r0 11 | mov 6(r5),0f 12 | mov 8(r5),0f+2 13 | sys 0; 9f 14 | bec 1f 15 | jmp cerror 16 | 1: 17 | clr r0 18 | mov (sp)+,r5 19 | rts pc 20 | .data 21 | 9: 22 | sys seek; 0:..; .. 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /usr/personal/user/src/communi/RcvPubMail.s: -------------------------------------------------------------------------------- 1 | #int RecivePublicMail(char *name, char *mail, int len, int time) 2 | #{ 3 | .globl _RecivePublicMail 4 | _RecivePublicMail: 5 | mov r5,-(sp) 6 | mov sp,r5 7 | mov 4(r5), r0 8 | mov 6(r5),0f 9 | mov 8(r5),0f+2 10 | mov 10(r5),0f+4 11 | sys 0; 9f 12 | bec 1f 13 | jmp cerror 14 | 1: 15 | mov (sp)+,r5 16 | rts pc 17 | .data 18 | 9: 19 | sys 68; 0: ..;..;.. 20 | #} 21 | -------------------------------------------------------------------------------- /usr/personal/user/src/communi/SendSharedMail.s: -------------------------------------------------------------------------------- 1 | #int SendSharedMail(int mbxd, char *mail, int len, int time) 2 | #{ 3 | .globl _SendSharedMail 4 | _SendSharedMail: 5 | mov r5,-(sp) 6 | mov sp,r5 7 | mov 4(r5), 0f 8 | mov 6(r5),0f+2 9 | mov 8(r5),0f+4 10 | mov 10(r5),0f+6 11 | sys 0; 9f 12 | bec 1f 13 | jmp cerror 14 | 1: 15 | mov (sp)+,r5 16 | rts pc 17 | .data 18 | 9: 19 | sys 65; 0: ..;..;..;.. 20 | #} 21 | -------------------------------------------------------------------------------- /usr/source/s/s5/open.s: -------------------------------------------------------------------------------- 1 | / C library -- open 2 | 3 | / file = open(string, mode) 4 | / 5 | / file == -1 means error 6 | //uchar 7 | .globl _open, cerror 8 | 9 | _open: 10 | mov r5,-(sp) 11 | mov sp,r5 12 | mov 4(r5),0f 13 | mov 6(r5),0f+2 14 | sys 0; 9f 15 | bec 1f 16 | jmp cerror 17 | 1: 18 | mov (sp)+,r5 19 | rts pc 20 | .data 21 | 9: 22 | sys open; 0:..; .. 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /usr/source/s/s4/creat.s: -------------------------------------------------------------------------------- 1 | 2 | / C library -- creat 3 | 4 | / file = creat(string, mode); 5 | / 6 | / file == -1 if error 7 | 8 | .globl _creat, cerror 9 | 10 | _creat: 11 | mov r5,-(sp) 12 | mov sp,r5 13 | mov 4(r5),0f 14 | mov 6(r5),0f+2 15 | sys 0; 9f 16 | bec 1f 17 | jmp cerror 18 | 1: 19 | mov (sp)+,r5 20 | rts pc 21 | .data 22 | 9: 23 | sys creat; 0:..; .. 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /usr/source/s/s5/mount.s: -------------------------------------------------------------------------------- 1 | / C library -- mount 2 | 3 | / error = mount(dev, file, flag) 4 | 5 | .globl _mount, cerror 6 | 7 | _mount: 8 | mov r5,-(sp) 9 | mov sp,r5 10 | mov 4(sp),0f 11 | mov 6(sp),0f+2 12 | mov 8(sp),0f+4 13 | sys 0; 9f 14 | bec 1f 15 | jmp cerror 16 | 1: 17 | clr r0 18 | mov (sp)+,r5 19 | rts pc 20 | .data 21 | 9: 22 | sys mount; 0:..; ..; .. 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /usr/personal/user/src/communi/CreatSharedMem.s: -------------------------------------------------------------------------------- 1 | #int CreateSharedMemory(char *name, int blocks, int ownpermin, int otherpermin) 2 | #{ 3 | .globl _CreateSharedMemory 4 | _CreateSharedMemory: 5 | mov r5,-(sp) 6 | mov sp,r5 7 | mov 4(r5),0f 8 | mov 6(r5),0f+2 9 | mov 8(r5),0f+4 10 | mov 10(r5),0f+6 11 | sys 0; 9f 12 | bec 1f 13 | jmp cerror 14 | 1: 15 | mov (sp)+,r5 16 | rts pc 17 | 9: 18 | sys 69; 0: ..;..;..;.. 19 | #} 20 | -------------------------------------------------------------------------------- /usr/sys/text.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Text structure. 3 | * One allocated per pure 4 | * procedure on swap device. 5 | * Manipulated by text.c 6 | */ 7 | struct text 8 | { 9 | int x_daddr; /* disk address of segment */ 10 | int x_caddr; /* core address, if loaded */ 11 | int x_size; /* size (*64) */ 12 | int *x_iptr; /* inode of prototype */ 13 | char x_count; /* reference count */ 14 | char x_ccount; /* number of loaded references */ 15 | } text[NTEXT]; -------------------------------------------------------------------------------- /usr/source/s/s5/write.s: -------------------------------------------------------------------------------- 1 | / C library -- write 2 | 3 | / nwritten = write(file, buffer, count); 4 | / 5 | / nwritten == -1 means error 6 | 7 | .globl _write, cerror 8 | 9 | _write: 10 | mov r5,-(sp) 11 | mov sp,r5 12 | mov 4(r5),r0 13 | mov 6(r5),0f 14 | mov 8(r5),0f+2 15 | sys 0; 9f 16 | bec 1f 17 | jmp cerror 18 | 1: 19 | mov (sp)+,r5 20 | rts pc 21 | .data 22 | 9: 23 | sys write; 0:..; .. 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /usr/source/s/solloc/getch.s: -------------------------------------------------------------------------------- 1 | .globl getchar 2 | .globl lookchar 3 | .globl w, r, a, l 4 | / 5 | / 6 | / routine to read next character from string 7 | / pointer to by r1; character returned in r0 8 | / c-bit set if character not availiable (eof) 9 | / 10 | / mov ...,r1 11 | / jsr pc,getchar 12 | / movb r0,... 13 | / 14 | getchar: 15 | jsr pc,lookchar 16 | bes 1f 17 | inc r(r1) 18 | tst r0 19 | 1: rts pc 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /usr/source/s/s5/mknod.s: -------------------------------------------------------------------------------- 1 | 2 | / C library -- mknod 3 | 4 | / error = mknod(string, mode, major.minor); 5 | 6 | .globl _mknod, cerror 7 | 8 | mknod = 14. 9 | _mknod: 10 | mov r5,-(sp) 11 | mov sp,r5 12 | mov 4(r5),0f 13 | mov 6(r5),0f+2 14 | mov 8(r5),0f+4 15 | sys 0; 9f 16 | bec 1f 17 | jmp cerror 18 | 1: 19 | clr r0 20 | mov (sp)+,r5 21 | rts pc 22 | .data 23 | 9: 24 | sys mknod; 0:..; ..; .. 25 | 26 | //read 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /usr/source/s/s5/read.s: -------------------------------------------------------------------------------- 1 | / C library -- read 2 | 3 | / nread = read(file, buffer, count); 4 | / 5 | / nread ==0 means eof; nread == -1 means error 6 | 7 | .globl _read, cerror 8 | 9 | _read: 10 | mov r5,-(sp) 11 | mov sp,r5 12 | mov 4(r5),r0 13 | mov 6(r5),0f 14 | mov 8(r5),0f+2 15 | sys 0; 9f 16 | bec 1f 17 | jmp cerror 18 | 1: 19 | mov (sp)+,r5 20 | rts pc 21 | .data 22 | 9: 23 | sys read; 0:..; .. 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /usr/source/s/s4/fstat.s: -------------------------------------------------------------------------------- 1 | / C library -- fstat 2 | 3 | / error = fstat(file, statbuf); 4 | 5 | / int statbuf[17] or 6 | / char statbuf[34] 7 | / as appropriate 8 | 9 | .globl _fstat, cerror 10 | 11 | _fstat: 12 | mov r5,-(sp) 13 | mov sp,r5 14 | mov 4(r5),r0 15 | mov 6(r5),0f 16 | sys 0; 9f 17 | bec 1f 18 | jmp cerror 19 | 1: 20 | clr r0 21 | mov (sp)+,r5 22 | rts pc 23 | .data 24 | 9: 25 | sys fstat; 0:.. 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /usr/source/s/s5/stat.s: -------------------------------------------------------------------------------- 1 | / C library -- stat 2 | 3 | / error = stat(string, statbuf); 4 | 5 | / int statbuf[18] or 6 | / char statbuf[36] 7 | / as appropriate 8 | 9 | .globl _stat, cerror 10 | 11 | _stat: 12 | mov r5,-(sp) 13 | mov sp,r5 14 | mov 4(r5),0f 15 | mov 6(r5),0f+2 16 | sys 0; 9f 17 | bec 1f 18 | jmp cerror 19 | 1: 20 | clr r0 21 | mov (sp)+,r5 22 | rts pc 23 | .data 24 | 9: 25 | sys stat; 0:..; .. 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /usr/source/s/s4/gtty.s: -------------------------------------------------------------------------------- 1 | / C library -- gtty 2 | 3 | / error = gtty(filep, ttyvec); 4 | 5 | / filep is descriptor of open tty 6 | / ttyvec[0, 1, 2] correspond to args of gtty 7 | 8 | .globl _gtty, cerror 9 | 10 | _gtty: 11 | mov r5,-(sp) 12 | mov sp,r5 13 | mov 4(r5),r0 14 | mov 6(r5),0f 15 | sys 0; 9f 16 | bec 1f 17 | jmp cerror 18 | 1: 19 | clr r0 20 | mov (sp)+,r5 21 | rts pc 22 | .data 23 | 9: 24 | sys gtty; 0:.. 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /usr/source/s/s5/stty.s: -------------------------------------------------------------------------------- 1 | / C library -- stty 2 | 3 | / error = stty(filep, ttyvec); 4 | 5 | / filep is descriptor of open tty 6 | / ttyvec[0, 1, 2] correspond to args of stty 7 | 8 | .globl _stty, cerror 9 | 10 | _stty: 11 | mov r5,-(sp) 12 | mov sp,r5 13 | mov 4(r5),r0 14 | mov 6(r5),0f 15 | sys 0; 9f 16 | bec 1f 17 | jmp cerror 18 | 1: 19 | clr r0 20 | mov (sp)+,r5 21 | rts pc 22 | .data 23 | 9: 24 | sys stty; 0:.. 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /usr/sys/file.h: -------------------------------------------------------------------------------- 1 | /* 2 | * One file structure is allocated 3 | * for each open/creat/pipe call. 4 | * Main use is to hold the read/write 5 | * pointer associated with each open 6 | * file. 7 | */ 8 | struct file 9 | { 10 | char f_flag; 11 | char f_count; /* reference count */ 12 | int f_inode; /* pointer to inode structure */ 13 | char *f_offset[2]; /* read/write character pointer */ 14 | } file[NFILE]; 15 | 16 | /* flags */ 17 | #define FREAD 01 18 | #define FWRITE 02 19 | #define FPIPE 04 -------------------------------------------------------------------------------- /usr/source/s/s5/ptrace.s: -------------------------------------------------------------------------------- 1 | / ptrace -- C library 2 | 3 | / result = ptrace(req, pid, addr, data); 4 | 5 | ptrace = 26. 6 | indir = 0 7 | 8 | .globl _ptrace 9 | .globl cerror, _errno 10 | 11 | _ptrace: 12 | mov r5,-(sp) 13 | mov sp,r5 14 | mov 4.(r5),0f+4 15 | mov 6.(r5),0f+0 16 | mov 8.(r5),0f+2 17 | mov 10.(r5),r0 18 | clr _errno 19 | sys indir; 9f 20 | bec 1f 21 | jmp cerror 22 | 1: 23 | mov (sp)+,r5 24 | rts pc 25 | 26 | .data 27 | 9: 28 | sys ptrace; 0: .=.+6 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /usr/source/cref/index/econs.h: -------------------------------------------------------------------------------- 1 | # define NUMA 14 2 | # define NUMC 128 3 | # define NUMS 3 4 | # define SIZA 8 5 | # define SIZC 2 6 | # define SIZS 8 7 | # define PTRI 509 8 | # define CHARI 4000 9 | # define PTRX 5147 10 | # define CHARX 40000 11 | # define CONT 0 12 | # define COLL 1 13 | # define SAVE 2 14 | # define OUT 3 15 | # define EGOBL 4 16 | # define SHARP 5 17 | # define PNO 6 18 | 19 | # define SKIP 0 20 | # define COLLECT 1 21 | # define SKIP2 2 22 | #define CREATC 0644 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /usr/source/s/s1/cpall.c: -------------------------------------------------------------------------------- 1 | char buf[100]; 2 | 3 | main(argc, argv) 4 | char **argv; 5 | { 6 | register i; 7 | register char *c1, *c2; 8 | 9 | if(argc < 3) { 10 | write(2, "arg count\n", 10); 11 | exit(); 12 | } 13 | argc--; 14 | c1 = buf; 15 | c2 = argv[argc]; 16 | while(*c1++ = *c2++); 17 | c1[-1] = '/'; 18 | *c1++ = '.'; 19 | *c1 = '\0'; 20 | for(i=1; i<argc; i++) { 21 | if(fork()==0) { 22 | execl("/bin/cp", "cp", argv[i], buf); 23 | exit(); 24 | } 25 | wait(); 26 | } 27 | } 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /usr/source/s/s4/getchr.s: -------------------------------------------------------------------------------- 1 | / getchar() -- get a character from input file fin 2 | 3 | .globl _getchar 4 | .comm _errno,2 5 | .comm _fin,518. 6 | 7 | _getchar: 8 | mov r5,-(sp) 9 | mov sp,r5 10 | dec _fin+2 11 | bge 1f 12 | mov $_fin+6,_fin+4 13 | mov _fin,r0 14 | sys read; _fin+6; 512. 15 | bes badret 16 | tst r0 17 | beq badret 18 | dec r0 19 | mov r0,_fin+2 20 | 1: 21 | clr r0 22 | bisb *_fin+4,r0 23 | inc _fin+4 24 | mov (sp)+,r5 25 | rts pc 26 | 27 | badret: 28 | mov r0,_errno 29 | clr r0 30 | clr _fin+2 31 | mov (sp)+,r5 32 | rts pc 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /usr/personal/user/src/TermThd.s: -------------------------------------------------------------------------------- 1 | #define TERMTHD 78 2 | int TerminateThread(int tid) 3 | { 4 | .globl _TerminateThread 5 | _TerminateThread: 6 | mov r5,-(sp) 7 | mov sp,r5 8 | mov r1, -(sp) 9 | mov 4(r5),r1 10 | cmp 0, r1 11 | blt me 12 | beq err 13 | mov r1, -(sp) 14 | jsr gettid 15 | cmp r0, r1 16 | beq me 17 | sys TERMTHD 18 | bec 2f 19 | jmp cerror 20 | 2: 21 | clr r0 22 | br 1f 23 | err: 24 | mov EINVTHDID, _errno 25 | mov -1, r0 26 | br 1f 27 | me: 28 | mov -1, -(sp) 29 | jsr ExitThread 30 | 31 | 1: 32 | mov (sp)+, r1 33 | mov (sp)+,r5 34 | rts pc 35 | #} 36 | -------------------------------------------------------------------------------- /usr/source/s/s5/reset.s: -------------------------------------------------------------------------------- 1 | / C library -- reset, setexit 2 | 3 | / reset() 4 | / will generate a "return" from 5 | / the last call to 6 | / setexit() 7 | / by restoring sp, r5 8 | / and doing a return. 9 | / 10 | / useful for going back to the main loop 11 | / after a horrible error in a lowlevel 12 | / routine. 13 | 14 | .globl _setexit 15 | .globl _reset 16 | .globl csv, cret 17 | 18 | _setexit: 19 | jsr r5,csv 20 | mov r5,sr5 21 | mov 2(r5),spc 22 | jmp cret 23 | 24 | _reset: 25 | mov sr5,r5 26 | mov spc,2(r5) 27 | jmp cret 28 | 29 | .bss 30 | sr5: .=.+2 31 | spc: .=.+2 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /usr/sys/seg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * KT-11 addresses and bits. 3 | */ 4 | 5 | #define UISD 0177600 /* first user I-space descriptor register */ 6 | #define UISA 0177640 /* first user I-space address register */ 7 | #define UDSA 0177660 /* first user D-space address register */ 8 | #define RO 02 /* access abilities */ 9 | #define WO 04 10 | #define RW 06 11 | #define ED 010 /* extend direction */ 12 | 13 | /* 14 | * structure used to address 15 | * a sequence of integers. 16 | */ 17 | struct 18 | { 19 | int r[]; 20 | }; 21 | int *ka6; /* 11/40 KISA6; 11/45 KDSA6 */ 22 | 23 | /* 24 | * address to access 11/70 UNIBUS map 25 | */ 26 | #define UBMAP 0170200 -------------------------------------------------------------------------------- /usr/sys/ino.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Inode structure as it appears on 3 | * the disk. Not used by the system, 4 | * but by things like check, df, dump. 5 | */ 6 | struct inode 7 | { 8 | int i_mode; 9 | char i_nlink; 10 | char i_uid; 11 | char i_gid; 12 | char i_size0; 13 | char *i_size1; 14 | int i_addr[8]; 15 | int i_atime[2]; 16 | int i_mtime[2]; 17 | }; 18 | 19 | /* modes */ 20 | #define IALLOC 0100000 21 | #define IFMT 060000 22 | #define IFDIR 040000 23 | #define IFCHR 020000 24 | #define IFBLK 060000 25 | #define ILARG 010000 26 | #define ISUID 04000 27 | #define ISGID 02000 28 | #define ISVTX 01000 29 | #define IREAD 0400 30 | #define IWRITE 0200 31 | #define IEXEC 0100 -------------------------------------------------------------------------------- /usr/source/cref/mcons.h: -------------------------------------------------------------------------------- 1 | # define NUMA 14 2 | # define NUMC 128 3 | # define NUMS 3 4 | # define SIZA 8 5 | # define SIZC 2 6 | # define SIZS 8 7 | # define PTRI 509 8 | # define CHARI 4000 9 | # define PTRX 509 10 | # define CHARX 4000 11 | # define CONT 1 12 | # define COLL 2 13 | # define SAVE 3 14 | # define OUT 4 15 | # define ASYM 5 16 | # define ASW 6 17 | # define CSYM 7 18 | # define CSW 8 19 | # define INCL 9 20 | # define DECL 10 21 | # define SK2 11 22 | # define SK 12 23 | # define TABS 13 24 | # define SEMI 14 25 | # define SHARP 15 26 | 27 | # define SKIP 0 28 | # define COLLECT 1 29 | # define SKIP2 2 30 | #define CREATC 0644 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /usr/source/cref/index.html: -------------------------------------------------------------------------------- 1 | 2 | Index of V6/usr/source/cref/index 3 |

V6/usr/source/cref/index

4 | 5 | 6 | 7 | 8 | 9 | 10 |
FileSizeDate
ecmn.h74414 May 1975
econs.h36214 May 1975
ind0.c553214 May 1975
ind1.c372514 May 1975
ind2.c54814 May 1975
11 | -------------------------------------------------------------------------------- /usr/source/s/s4/execv.s: -------------------------------------------------------------------------------- 1 | / C library -- execv 2 | 3 | / execv(file, argv); 4 | / 5 | / where argv is a vector argv[0] ... argv[x], 0 6 | / last vector element must be 0 7 | / 8 | / The _exectrap flags is used by the debugger and causes 9 | / a trace trap on the first instruction of the executed instruction 10 | / to give a chance to set breakpoints. 11 | 12 | .globl _execv, cerror 13 | .comm __exectrap,2 14 | rtt = 6 15 | 16 | _execv: 17 | mov r5,-(sp) 18 | mov sp,r5 19 | mov 4(r5),0f 20 | mov 6(r5),0f+2 21 | tst __exectrap 22 | beq 1f 23 | mov $170020,-(sp) / t-bit 24 | mov $1f,-(sp) 25 | rtt 26 | 1: 27 | sys 0; 9f 28 | jmp cerror 29 | .data 30 | 9: 31 | sys exec; 0:..; .. 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /usr/source/c/run: -------------------------------------------------------------------------------- 1 | cc -c -O c0[012345].c 2 | cc -c -O c1[0123].c 3 | as c1t.s; mv a.out c1t.o 4 | cc cvopt.c 5 | a.out table.s table.i 6 | as table.i; mv a.out table.o 7 | cc -c -O c2[01].c 8 | 9 | ed c0t.s 10 | g/fpp =/s/1/0/ 11 | w 12 | q 13 | as c0t.s; mv a.out c0t.o 14 | cc -s -n c0?.o 15 | cmp a.out /lib/c0 16 | cp a.out /lib/c0 17 | 18 | ed c0t.s 19 | g/fpp =/s/0/1/ 20 | w 21 | q 22 | as c0t.s; mv a.out c0t.o 23 | cc -f -s -n c0?.o 24 | cmp a.out /lib/fc0 25 | cp a.out /lib/fc0 26 | 27 | cc -s -n c1?.o table.o 28 | cmp a.out /lib/c1 29 | cp a.out /lib/c1 30 | 31 | cc -f -s -n c1?.o table.o 32 | cmp a.out /lib/fc1 33 | cp a.out /lib/fc1 34 | 35 | cc -s -n c2?.o 36 | cmp a.out /lib/c2 37 | cp a.out /lib/c2 38 | 39 | rm *.o table.i a.out 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /usr/source/s/s2/size.c: -------------------------------------------------------------------------------- 1 | /* 2 | size -- determine object size 3 | 4 | */ 5 | 6 | main(argc, argv) 7 | char **argv; 8 | { 9 | int buf[010], f, ac, sum; 10 | 11 | ac = argc; 12 | if (ac==1) { 13 | *argv = "a.out"; 14 | ac++; 15 | --argv; 16 | } 17 | while(--ac) { 18 | ++argv; 19 | if((f=open(*argv, 0))<0) { 20 | printf("%s not found\n", *argv); 21 | continue; 22 | } 23 | read(f, buf, 0020); 24 | if(buf[0]!=0411 && buf[0]!=0410 && buf[0]!=0407) { 25 | printf("Bad format: %s\n", *argv); 26 | close(f); 27 | continue; 28 | } 29 | if (argc>2) 30 | printf("%s: ", *argv); 31 | printf("%l+%l+%l=", buf[1],buf[2],buf[3]); 32 | sum = buf[1]+buf[2]+buf[3]; 33 | printf("%l (%o)\n", sum, sum); 34 | close(f); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /usr/sys/dmr/partab.c: -------------------------------------------------------------------------------- 1 | char partab[] { 2 | 0001,0201,0201,0001,0201,0001,0001,0201, 3 | 0202,0004,0003,0205,0005,0206,0201,0001, 4 | 0201,0001,0001,0201,0001,0201,0201,0001, 5 | 0001,0201,0201,0001,0201,0001,0001,0201, 6 | 0200,0000,0000,0200,0000,0200,0200,0000, 7 | 0000,0200,0200,0000,0200,0000,0000,0200, 8 | 0000,0200,0200,0000,0200,0000,0000,0200, 9 | 0200,0000,0000,0200,0000,0200,0200,0000, 10 | 0200,0000,0000,0200,0000,0200,0200,0000, 11 | 0000,0200,0200,0000,0200,0000,0000,0200, 12 | 0000,0200,0200,0000,0200,0000,0000,0200, 13 | 0200,0000,0000,0200,0000,0200,0200,0000, 14 | 0000,0200,0200,0000,0200,0000,0000,0200, 15 | 0200,0000,0000,0200,0000,0200,0200,0000, 16 | 0200,0000,0000,0200,0000,0200,0200,0000, 17 | 0000,0200,0200,0000,0200,0000,0000,0201 18 | }; -------------------------------------------------------------------------------- /usr/source/cref/run: -------------------------------------------------------------------------------- 1 | chdir tab 2 | cc mtab.c 3 | a.out atable atab 4 | a.out ctable ctab 5 | a.out etable etab 6 | cmp atab /usr/lib/atab 7 | cp atab /usr/lib/atab 8 | cmp ctab /usr/lib/ctab 9 | cp ctab /usr/lib/ctab 10 | cmp etab /usr/lib/etab 11 | cp etab /usr/lib/etab 12 | rm a.out atab ctab etab 13 | 14 | chdir ../src 15 | cc -s -O upost.c 16 | cmp a.out /usr/bin/upost 17 | cp a.out /usr/bin/upost 18 | cc -s -O crpost.c 19 | cmp a.out /usr/bin/crpost 20 | cp a.out /usr/bin/crpost 21 | cc -s -O dr.c acts.c put.c 22 | cmp a.out /usr/bin/cref 23 | cp a.out /usr/bin/cref 24 | rm a.out *.o 25 | 26 | chdir ../index 27 | cc -s -O ind?.c 28 | cmp a.out /usr/bin/index 29 | cp a.out /usr/bin/index 30 | rm a.out *.o 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /usr/source/s/s5/sbrk.s: -------------------------------------------------------------------------------- 1 | /old = sbrk(increment); 2 | / 3 | /sbrk gets increment more core, and returns a pointer 4 | / to the beginning of the new core area 5 | / 6 | .globl _sbrk,_end, cerror 7 | 8 | _sbrk: 9 | mov r5,-(sp) 10 | mov sp,r5 11 | mov nd,0f 12 | add 4(r5),0f 13 | sys 0; 9f 14 | bec 1f 15 | jmp cerror 16 | 1: 17 | mov nd,r0 18 | add 4(r5),nd 19 | mov (sp)+,r5 20 | rts pc 21 | 22 | .globl _brk 23 | / brk(value) 24 | / as described in man2. 25 | / returns 0 for ok, -1 for error. 26 | 27 | _brk: 28 | mov r5,-(sp) 29 | mov sp,r5 30 | mov 4(r5),0f 31 | sys 0; 9f 32 | bec 1f 33 | jmp cerror 34 | 1: 35 | mov 4(r5),nd 36 | clr r0 37 | mov (sp)+,r5 38 | rts pc 39 | 40 | .data 41 | 9: 42 | sys break; 0:.. 43 | nd: _end 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /usr/source/s/s2/mknod.c: -------------------------------------------------------------------------------- 1 | main(argc, argv) 2 | int argc; 3 | char **argv; 4 | { 5 | int m, a, b; 6 | 7 | if(argc != 5) { 8 | printf("arg count\n"); 9 | goto usage; 10 | } 11 | if(*argv[2] == 'b') 12 | m = 0160666; else 13 | if(*argv[2] == 'c') 14 | m = 0120666; else 15 | goto usage; 16 | a = number(argv[3]); 17 | if(a < 0) 18 | goto usage; 19 | b = number(argv[4]); 20 | if(b < 0) 21 | goto usage; 22 | if(mknod(argv[1], m, (a<<8)|b) < 0) 23 | perror("mknod"); 24 | exit();//read 25 | 26 | usage: 27 | printf("usage: mknod name b/c major minor\n"); 28 | } 29 | 30 | number(s) 31 | char *s; 32 | { 33 | int n, c; 34 | 35 | n = 0; 36 | while(c = *s++) { 37 | if(c<'0' || c>'9') 38 | return(-1); 39 | n = n*10 + c-'0'; 40 | } 41 | return(n); 42 | } 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /usr/source/s/s2/sync.c: -------------------------------------------------------------------------------- 1 | 2 | V6/usr/source/s2/sync.c 3 |

V6/usr/source/s2/sync.c

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | main()
19 | {
20 | 
21 | 	sync();
22 | }
23 | 
24 | 
25 | 
26 | 
27 | 
28 | 
29 | 
30 | 
31 | 
32 | 
33 | 
34 | 


--------------------------------------------------------------------------------
/usr/source/cref/index/ind2.c:
--------------------------------------------------------------------------------
 1 | 
 2 | int	optr;
 3 | 
 4 | char	obuf[512];
 5 | 
 6 | int	nflush;
 7 | 
 8 | put(string,n)
 9 | 	char	*string;
10 | {
11 | 	extern	utmp;
12 | 	int	i;
13 | 	char	*o;
14 | 
15 | /*printf("%d %c %d\n",fil,*string,n);/*DEBUG*/
16 | 
17 | 	string--;
18 | 
19 | 	if((i = optr + n - 512) >= 0) {
20 | 		n =- i;
21 | 		o = &obuf[optr] -1;
22 | 		while(--n >= 0)
23 | 			*++o = *++string;
24 | 		optr = 512;
25 | 		flsh(1);
26 | 		n = i;
27 | 	}
28 | 
29 | 	o = &obuf[optr] - 1;
30 | 	optr =+ n;
31 | 
32 | 	while(--n >= 0) {
33 | 		*++o = *++string;
34 | 	}
35 | 	return(0);
36 | }
37 | 
38 | flsh(fil)
39 | {
40 | 	extern	tp[],utmp;
41 | 
42 | 	if(optr <= 0)	return(optr);
43 | 
44 | 	nflush++;
45 | 	if(write(tp[0],obuf,optr) != optr)
46 | 		return(-1);
47 | 	optr = 0;
48 | 	return(0);
49 | }
50 | 
51 | 
52 | 
53 | 
54 | 
55 | 
56 | 
57 | 
58 | 
59 | 
60 | 
61 | 
62 | 


--------------------------------------------------------------------------------
/usr/source/s/s1/exit.c:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s1/exit.c
 3 | 

V6/usr/source/s1/exit.c

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | /* exit -- end runcom */
19 | 
20 | main() {
21 | 	seek(0, 0, 2);
22 | }
23 | 
24 | 
25 | 
26 | 
27 | 
28 | 
29 | 
30 | 
31 | 
32 | 
33 | 
34 | 


--------------------------------------------------------------------------------
/usr/source/s/s4/hmul.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s4/hmul.s
 3 | 

V6/usr/source/s4/hmul.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | .globl	_hmul
19 | 
20 | _hmul:
21 | 	mov	2(sp),r0
22 | 	mul	4(sp),r0
23 | 	rts	pc
24 | 
25 | 
26 | 
27 | 
28 | 
29 | 
30 | 
31 | 
32 | 
33 | 
34 | 
35 | 


--------------------------------------------------------------------------------
/usr/source/s/sno/run:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/sno/run
 3 | 

V6/usr/source/sno/run

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | cc -s -O sno?.c
19 | cmp a.out /usr/bin/sno
20 | cp a.out /usr/bin/sno
21 | rm *.o a.out
22 | 
23 | 
24 | 
25 | 
26 | 
27 | 
28 | 
29 | 
30 | 
31 | 
32 | 
33 | -------------------------------------------------------------------------------- /usr/source/s/s3/savr5.s: -------------------------------------------------------------------------------- 1 | 2 | V6/usr/source/s3/savr5.s 3 |

V6/usr/source/s3/savr5.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | / savr5 - for as progs that call c-callable entries
19 | 
20 | .globl	savr5
21 | .bss
22 | savr5:	.=.+2
23 | 
24 | 
25 | 
26 | 
27 | 
28 | 
29 | 
30 | 
31 | 
32 | 
33 | 
34 | 


--------------------------------------------------------------------------------
/usr/source/s/s4/abort.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s4/abort.s
 3 | 

V6/usr/source/s4/abort.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | / C library -- abort
19 | 
20 | .globl	_abort
21 | iot	= 4
22 | 
23 | _abort:
24 | 	mov	r5,-(sp)
25 | 	mov	sp,r5
26 | 	iot
27 | 	mov	(sp)+,r5
28 | 	rts	pc
29 | 
30 | 
31 | 
32 | 
33 | 
34 | 
35 | 
36 | 
37 | 
38 | 
39 | 
40 | 


--------------------------------------------------------------------------------
/usr/sys/dmr/sys.c:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *	indirect driver for controlling tty.
 3 |  */
 4 | #include "../param.h"
 5 | #include "../conf.h"
 6 | #include "../user.h"
 7 | #include "../tty.h"
 8 | #include "../proc.h"
 9 |  
10 | syopen(dev, flag)
11 | {
12 | 	register *tp;
13 |  
14 | 	if(tp = syttyp())
15 | 	(*cdevsw[tp->t_dev.d_major].d_open)(tp->t_dev, flag);
16 | }
17 |  
18 | syread(dev)
19 | {
20 | 	register *tp;
21 |  
22 | 	if(tp = syttyp())
23 | 	(*cdevsw[tp->t_dev.d_major].d_read)(tp->t_dev);
24 | }
25 |  
26 | sywrite(dev)
27 | {
28 | 	register *tp;
29 |  
30 | 	if(tp = syttyp())
31 | 	(*cdevsw[tp->t_dev.d_major].d_write)(tp->t_dev);
32 | }
33 |  
34 | sysgtty(dev, flag)
35 | {
36 | 	register *tp;
37 |  
38 | 	if(tp = syttyp())
39 | 	(*cdevsw[tp->t_dev.d_major].d_sgtty)(tp->t_dev, flag);
40 | }
41 |  
42 | syttyp()
43 | {
44 | 	register tp;
45 |  
46 | 	tp = u.u_procp->p_ttyp;
47 | 	if(tp == NULL)
48 | 		u.u_error = ENXIO;
49 | 	return(tp);
50 | }


--------------------------------------------------------------------------------
/usr/source/s/s4/ffltpr.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s4/ffltpr.s
 3 | 

V6/usr/source/s4/ffltpr.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | / C library-- fake floating output
19 | 
20 | .globl	pfloat
21 | .globl	pscien
22 | 
23 | pfloat:
24 | pscien:
25 | 	add	$8,r4
26 | 	movb	$'?,(r3)+
27 | 	rts	pc
28 | 
29 | 
30 | 
31 | 
32 | 
33 | 
34 | 
35 | 
36 | 
37 | 
38 | 
39 | 


--------------------------------------------------------------------------------
/usr/source/s/s4/ldfps.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s4/ldfps.s
 3 | 

V6/usr/source/s4/ldfps.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | ldfps = 170100^tst
19 | /
20 | / ldfps(number);
21 | 
22 | .globl	_ldfps
23 | _ldfps:
24 | 	mov	r5,-(sp)
25 | 	mov	sp,r5
26 | 	ldfps	4(r5)
27 | 	mov	(sp)+,r5
28 | 	rts	pc
29 | 
30 | 
31 | 
32 | 
33 | 
34 | 
35 | 
36 | 
37 | 
38 | 
39 | 
40 | 


--------------------------------------------------------------------------------
/usr/source/s/s2/su.c:
--------------------------------------------------------------------------------
 1 | /* su -- become super-user */
 2 | 
 3 | char	password[100];
 4 | char	pwbuf[100];
 5 | int	ttybuf[3];
 6 | main()
 7 | {
 8 | 	register char *p, *q;
 9 | 	extern fin;
10 | 
11 | 	if(getpw(0, pwbuf))
12 | 		goto badpw;
13 | 	(&fin)[1] = 0;
14 | 	p = pwbuf;
15 | 	while(*p != ':')
16 | 		if(*p++ == '\0')
17 | 			goto badpw;
18 | 	if(*++p == ':')
19 | 		goto ok;
20 | 	gtty(0, ttybuf);
21 | 	ttybuf[2] =& ~010;
22 | 	stty(0, ttybuf);
23 | 	printf("password: ");
24 | 	q = password;
25 | 	while((*q = getchar()) != '\n')
26 | 		if(*q++ == '\0')
27 | 			return;
28 | 	*q = '\0';
29 | 	ttybuf[2] =| 010;
30 | 	stty(0, ttybuf);
31 | 	printf("\n");
32 | 	q = crypt(password);
33 | 	while(*q++ == *p++);
34 | 	if(*--q == '\0' && *--p == ':')
35 | 		goto ok;
36 | 	goto error;
37 | 
38 | badpw:
39 | 	printf("bad password file\n");
40 | ok:
41 | 	setuid(0);
42 | 	execl("/bin/sh", "-", 0);
43 | 	printf("cannot execute shell\n");
44 | error:
45 | 	printf("sorry\n");
46 | }
47 | 
48 | 
49 | 
50 | 
51 | 


--------------------------------------------------------------------------------
/usr/source/s/s1/echo.c:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s1/echo.c
 3 | 

V6/usr/source/s1/echo.c

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | main(argc, argv)
19 | int argc;
20 | char *argv[];
21 | {
22 | 	int i;
23 | 
24 | 	argc--;
25 | 	for(i=1; i<=argc; i++)
26 | 		printf("%s%c", argv[i], i==argc? '\n': ' ');
27 | }
28 | 
29 | 
30 | 
31 | 
32 | 
33 | 
34 | 
35 | 
36 | 
37 | 
38 | 
39 | 


--------------------------------------------------------------------------------
/usr/source/s/s3/fakfp.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s3/fakfp.s
 3 | 

V6/usr/source/s3/fakfp.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | / fakefp -- fake floating point simulator
19 | 
20 | .globl	fptrap
21 | 
22 | fptrap:
23 | 	sub	$2,(sp)
24 | 	mov	r0,-(sp)
25 | 	sys	signal; 4; 0
26 | 	mov	(sp)+,r0
27 | 	2	/ rti
28 | 
29 | 
30 | 
31 | 
32 | 
33 | 
34 | 
35 | 
36 | 
37 | 
38 | 
39 | 


--------------------------------------------------------------------------------
/usr/source/s/s4/abs.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s4/abs.s
 3 | 

V6/usr/source/s4/abs.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | / abs - int absolute value.
19 | / fabs - floating abs
20 | 
21 | .globl	_abs
22 | _abs:
23 | 	mov	2(sp),r0
24 | 	bge	1f
25 | 	neg	r0
26 | 1:
27 | 	rts	pc
28 | 
29 | .globl	_fabs
30 | _fabs:
31 | 	movf	2(sp),fr0
32 | 	absf	fr0
33 | 	rts	pc
34 | 
35 | 
36 | 
37 | 
38 | 
39 | 
40 | 
41 | 
42 | 
43 | 
44 | 
45 | 


--------------------------------------------------------------------------------
/usr/source/s/s2/update.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s2/update.s
 3 | 

V6/usr/source/s2/update.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | 	sys	fork
19 | 		br 1f
20 | 	sys	exit
21 | 1:
22 | 	clr	r0
23 | 	sys	close
24 | 	mov	$1,r0
25 | 	sys	close
26 | 	mov	$2,r0
27 | 	sys	close
28 | 1:
29 | 	sys	sync
30 | 	mov	$30.,r0
31 | 	sys	sleep
32 | 	br	1b
33 | sleep = 35.
34 | sync = 36.
35 | 
36 | 
37 | 
38 | 
39 | 
40 | 
41 | 
42 | 
43 | 
44 | 
45 | 
46 | 


--------------------------------------------------------------------------------
/usr/source/s/s3/ttyn.s:
--------------------------------------------------------------------------------
 1 | / return name of current tty
 2 | 
 3 | .globl	 ttyn, _ttyn		//ttyn(int fd), find the previous opened file fd and check whether it's the file "/dev/tty*". If found it in "/dev",
 4 | 					//return *, else return x.
 5 | _ttyn:
 6 | 	mov	r5,-(sp)
 7 | 	mov	sp,r5
 8 | 	mov	4(r5),r0
 9 | 	jsr	pc,1f
10 | 	mov	(sp)+,r5
11 | 	rts	pc
12 | 
13 | ttyn:
14 | 	clr	r0
15 | 1:
16 | 	mov	$'x,name
17 | 	tst	-(sp)
18 | 	sys	fstat; buf
19 | 	bes	er1
20 | 	mov	buf+2,(sp)
21 | 	sys	open; dev; 0
22 | 	bes	er1
23 | 	mov	r0,r1
24 | 1:
25 | 	mov	r1,r0
26 | 	sys	read; buf; 16.
27 | 	bes	er
28 | 	cmp	r0,$16.
29 | 	bne	er
30 | 	mov	$buf,r0
31 | 	cmp	(r0)+,(sp)
32 | 	bne	1b
33 | 	cmp	(r0)+,$"tt
34 | 	bne	1b
35 | 	cmpb	(r0)+,$'y
36 | 	bne	1b
37 | 	tstb	(r0)+
38 | 	beq	1b
39 | 	cmpb	(r0),$'\0
40 | 	bne	1b
41 | 	movb	-(r0),name
42 | 
43 | er:
44 | 	mov	r1,r0
45 | 	sys	close
46 | 
47 | er1:
48 | 	tst	(sp)+
49 | 	movb	name,r0
50 | 	rts	pc
51 | 
52 | .data
53 | dev:	
54 | .even
55 | .bss
56 | buf:	.=.+40.
57 | name:	.=.+2
58 | 
59 | 
60 | 
61 | 
62 | 
63 | 
64 | 
65 | 
66 | 
67 | 
68 | 
69 | 


--------------------------------------------------------------------------------
/usr/sys/filesys.h:
--------------------------------------------------------------------------------
 1 | /*
 2 |  * Definition of the unix super block.
 3 |  * The root super block is allocated and
 4 |  * read in iinit/alloc.c. Subsequently
 5 |  * a super block is allocated and read
 6 |  * with each mount (smount/sys3.c) and
 7 |  * released with unmount (sumount/sys3.c).
 8 |  * A disk block is ripped off for storage.
 9 |  * See alloc.c for general alloc/free
10 |  * routines for free list and I list.
11 |  */
12 | struct	filsys
13 | {
14 | 	int	s_isize;	/* size in blocks of I list */
15 | 	int	s_fsize;	/* size in blocks of entire volume */
16 | 	int	s_nfree;	/* number of in core free blocks (0-100) */
17 | 	int	s_free[100];	/* in core free blocks */
18 | 	int	s_ninode;	/* number of in core I nodes (0-100) */
19 | 	int	s_inode[100];	/* in core free I nodes */
20 | 	char	s_flock;	/* lock during free list manipulation */
21 | 	char	s_ilock;	/* lock during I list manipulation */
22 | 	char	s_fmod;		/* super block modified flag */
23 | 	char	s_ronly;	/* mounted read-only flag */
24 | 	int	s_time[2];	/* current date of last update */
25 | 	int	pad[50];
26 | };


--------------------------------------------------------------------------------
/usr/personal/kernel/src/text.c:
--------------------------------------------------------------------------------
 1 | /*
 2 |  * Swap out process p.
 3 |  * The ff flag causes its core to be freed--
 4 |  * it may be off when called to create an image for a
 5 |  * child process in newproc.
 6 |  * Os is the old size of the data area of the process,
 7 |  * and is supplied during core expansion swaps.
 8 |  *
 9 |  * panic: out of swap space
10 |  * panic: swap error -- IO error
11 |  */
12 | xswap(p, ff, os)
13 | int *p;
14 | {
15 | 	register *rp, a;
16 |  
17 | 	rp = p;
18 | 	b = ShmSize(rp, 0);
19 | 	if(os == 0)
20 | 		os = rp->p_size;
21 | 	//a = malloc(swapmap, (rp->p_size+7)/8);
22 | 	 a = malloc(swapmap, (rp->p_size+b/PHY_MEM_BLOCK_SIZE+7)/8);
23 | 	if(a == NULL)
24 | 		panic("out of swap space");
25 | 	xccdec(rp->p_textp);
26 | 	rp->p_flag =| SLOCK;
27 | 	if(swap(a, rp->p_addr, os, 0))
28 | 		panic("swap error");
29 | 	if(ff)
30 | 	{
31 | 		mfree(coremap, os, rp->p_addr);
32 | 		FreeShm(rp);
33 | 	}
34 | 	rp->p_addr = a;
35 | 	rp->p_flag =& ~(SLOAD|SLOCK);
36 | 	rp->p_time = 0;
37 | 	if(runout) {
38 | 		runout = 0;
39 | 		wakeup(&runout);
40 | 	}
41 | }


--------------------------------------------------------------------------------
/usr/source/s/s4/crt0.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s4/crt0.s
 3 | 

V6/usr/source/s4/crt0.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | / C runtime startoff
19 | 
20 | .globl	savr5
21 | .globl	_exit
22 | 
23 | .globl	_main
24 | 
25 | start:
26 | 	setd
27 | 	mov	sp,r0
28 | 	mov	(r0),-(sp)
29 | 	tst	(r0)+
30 | 	mov	r0,2(sp)
31 | 	jsr	pc,_main
32 | 	mov	r0,(sp)
33 | 	jsr	pc,*$_exit
34 | 	sys	exit
35 | 
36 | .bss
37 | savr5:	.=.+2
38 | 
39 | 
40 | 
41 | 
42 | 
43 | 
44 | 
45 | 
46 | 
47 | 
48 | 
49 | 


--------------------------------------------------------------------------------
/usr/source/s/s3/dpadd.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s3/dpadd.s
 3 | 

V6/usr/source/s3/dpadd.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | / C library -- signed dp add
19 | 
20 | / dpadd(l, i)
21 | /	int l[2];
22 | / l =+ i;
23 | 
24 | .globl	_dpadd
25 | 
26 | _dpadd:
27 | 	mov	r5,-(sp)
28 | 	mov	sp,r5
29 | 	mov	4(r5),r0
30 | 	tst	6(r5)
31 | 	sxt	r1
32 | 	add	r1,(r0)+
33 | 	add	6(r5),(r0)
34 | 	adc	-(r0)
35 | 	mov	(sp)+,r5
36 | 	rts	pc
37 | 
38 | 
39 | 
40 | 
41 | 
42 | 
43 | 
44 | 
45 | 
46 | 
47 | 
48 | 


--------------------------------------------------------------------------------
/usr/source/s/s5/mcount.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s5/mcount.s
 3 | 

V6/usr/source/s5/mcount.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | / count subroutine calls during profiling
19 | 
20 | .globl	mcount
21 | .comm	countbase,2
22 | 
23 | mcount:
24 | 	mov	(r0),r1
25 | 	bne	1f
26 | 	mov	countbase,r1
27 | 	beq	2f
28 | 	add	$6,countbase
29 | 	mov	(sp),(r1)+
30 | 	mov	r1,(r0)
31 | 1:
32 | 	inc	2(r1)
33 | 	bne	2f
34 | 	inc	(r1)
35 | 2:
36 | 	rts	pc
37 | 
38 | 
39 | 
40 | 
41 | 
42 | 
43 | 
44 | 
45 | 
46 | 
47 | 
48 | 
49 | 


--------------------------------------------------------------------------------
/usr/source/s/s5/mdate.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s5/mdate.s
 3 | 

V6/usr/source/s5/mdate.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | / C library-- mdate
19 | 
20 | .globl	_mdate, cerror
21 | 
22 | _mdate:
23 | 	mov	r5,-(sp)
24 | 	mov	sp,r5
25 | 	mov	4(r5),0f
26 | 	mov	6(r5),r1
27 | 	mov	(r1)+,r0
28 | 	mov	(r1),r1
29 | 	sys	0; 9f
30 | 	bec	1f
31 | 	jmp	cerror
32 | 1:
33 | 	clr	r0
34 | 	mov	(sp)+,r5
35 | 	rts	pc
36 | .data
37 | 9:
38 | 	sys	mdate; 0:..
39 | 
40 | 
41 | 
42 | 
43 | 
44 | 
45 | 
46 | 
47 | 
48 | 
49 | 
50 | 


--------------------------------------------------------------------------------
/usr/source/s/s3/ldiv.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s3/ldiv.s
 3 | 

V6/usr/source/s3/ldiv.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | / C library-- long divide/remainder
19 | 
20 | .globl	_ldiv, _ldivr
21 | .globl	_lrem
22 | 
23 | _ldiv:
24 | 	mov	2(sp),r0
25 | 	mov	4(sp),r1
26 | 	div	6(sp),r0
27 | 	mov	r1,_ldivr
28 | 	rts	pc
29 | 
30 | _lrem:
31 | 	mov	2(sp),r0
32 | 	mov	4(sp),r1
33 | 	div	6(sp),r0
34 | 	mov	r1,r0
35 | 	rts	pc
36 | 
37 | .bss
38 | _ldivr:	.=.+2
39 | 
40 | 
41 | 
42 | 
43 | 
44 | 
45 | 
46 | 
47 | 
48 | 
49 | 
50 | 


--------------------------------------------------------------------------------
/usr/source/s/s5/nargs.s:
--------------------------------------------------------------------------------
 1 | / C library -- nargs
 2 | 
 3 | / WARNING: this routine does not work
 4 | / with user I&D space separate.
 5 | / Moreover, due to a design botch in
 6 | / the 11/45, it cannot be made to work
 7 | / by adding mfpi instructions.
 8 | 
 9 | .globl	_nargs
10 | 
11 | _nargs:
12 | 	mov	r5,-(sp)
13 | 	mov	2(r5),r1		/ pc of caller of caller
14 | 	mov	sp,r5
15 | 	clr	r0
16 | 	cmp	-4(r1),jsrsd
17 | 	bne	8f
18 | 	mov	$2,r0
19 | 8:
20 | 	cmp	(r1),tsti
21 | 	bne	1f
22 | 	add	$2,r0
23 | 	br	2f
24 | 1:
25 | 	cmp	(r1),cmpi
26 | 	bne	1f
27 | 	add	$4,r0
28 | 	br	2f
29 | 1:
30 | 	cmp	(r1),addi
31 | 	bne	1f
32 | 	add	2(r1),r0
33 | 	br	2f
34 | 1:
35 | 	cmp	(r1),jmpi
36 | 	bne	1f
37 | 	add	2(r1),r1
38 | 	add	$4,r1
39 | 	br	8b
40 | 1:
41 | 	cmpb	1(r1),bri+1
42 | 	bne	2f
43 | 	mov	r0,-(sp)
44 | 	mov	(r1),r0
45 | 	swab	r0
46 | 	ash	$-7,r0
47 | 	add	r0,r1
48 | 	add	$2,r1
49 | 	mov	(sp)+,r0
50 | 	br	8b
51 | 2:
52 | 	asr	r0
53 | 	mov	(sp)+,r5
54 | 	rts	pc
55 | 
56 | .data
57 | jsrsd:	jsr	pc,*$0
58 | tsti:	tst	(sp)+
59 | cmpi:	cmp	(sp)+,(sp)+
60 | addi:	add	$0,sp
61 | jmpi:	jmp	0
62 | bri:	br	.
63 | 
64 | 
65 | 
66 | 
67 | 
68 | 
69 | 
70 | 
71 | 
72 | 
73 | 
74 | 


--------------------------------------------------------------------------------
/usr/source/s/s1/kill.s:
--------------------------------------------------------------------------------
 1 | / kill process
 2 | 
 3 | 	mov	(sp)+,r4
 4 | 	tst	(sp)+
 5 | 
 6 | loop:
 7 | 	dec	r4
 8 | 	ble	done
 9 | 	mov	(sp)+,r5
10 | 	clr	r3
11 | 	cmpb	(r5),$'-
12 | 	bne	1f
13 | 	inc	r5
14 | 	clr	signo
15 | 1:
16 | 	movb	(r5)+,r0
17 | 	beq	1f
18 | 	sub	$'0,r0
19 | 	cmp	r0,$9
20 | 	bhi	error
21 | 	mul	$10.,r3
22 | 	add	r0,r3
23 | 	br	1b
24 | 1:
25 | 	tst	signo
26 | 	bne	1f
27 | 	tst	r3
28 | 	ble	error
29 | 	cmp	r3,$12.
30 | 	bgt	error
31 | 	mov	r3,signo
32 | 	br	loop
33 | 1:
34 | 	mov	r3,r0
35 | 	sys	37.; signo: 9.		/ kill
36 | 	bec	loop
37 | 	mov	r3,r0
38 | 	jsr	pc,decml
39 | 	mov	$1,r0
40 | 	sys	write; m1; em1-m1
41 | 	br	loop
42 | 
43 | error:
44 | 	mov	$1,r0
45 | 	sys	write; m2; em2-m2
46 | 	br	loop
47 | 
48 | done:
49 | 	sys	exit
50 | 
51 | decml:
52 | 	mov	r0,r1
53 | 	clr	r0
54 | 	div	$10.,r0
55 | 	mov	r1,-(sp)
56 | 	tst	r0
57 | 	beq	1f
58 | 	jsr	pc,decml
59 | 1:
60 | 	mov	(sp)+,r0
61 | 	add	$'0,r0
62 | 	mov	r0,ch
63 | 	mov	$1,r0
64 | 	sys	write; ch; 1
65 | 	rts	pc
66 | 
67 | m1:
68 | 	<: not found\n>
69 | em1:
70 | m2:
71 | 	<non-numeric arg\n>
72 | em2:
73 | .bss
74 | ch:	.=.+2
75 | 
76 | 
77 | 
78 | 
79 | 
80 | 
81 | 
82 | 
83 | 
84 | 
85 | 
86 | 


--------------------------------------------------------------------------------
/usr/source/s/s3/fmod.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s3/fmod.s
 3 | 

V6/usr/source/s3/fmod.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | / C floating mod
19 | / fmod(a,b) returns a number n such that
20 | /	i*b + n is a and 0 <= n < b
21 | 
22 | .globl	_fmod
23 | _fmod:
24 | 	mov	r5,-(sp)
25 | 	mov	sp,r5
26 | 	movf	4(r5),fr0
27 | 	divf	12.(r5),fr0
28 | 	modf	$one,fr0
29 | 	mulf	12.(r5),fr1
30 | 	movf	4(r5),fr0
31 | 	subf	fr1,fr0
32 | 	mov	(sp)+,r5
33 | 	rts	pc
34 | one = 40200
35 | 
36 | 
37 | 
38 | 
39 | 
40 | 
41 | 
42 | 
43 | 
44 | 
45 | 
46 | 


--------------------------------------------------------------------------------
/usr/source/s/s4/csv.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s4/csv.s
 3 | 

V6/usr/source/s4/csv.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | / C register save and restore -- version 12/74
19 | 
20 | .globl	csv
21 | .globl	cret
22 | 
23 | csv:
24 | 	mov	r5,r0
25 | 	mov	sp,r5
26 | 	mov	r4,-(sp)
27 | 	mov	r3,-(sp)
28 | 	mov	r2,-(sp)
29 | 	tst	-(sp)
30 | 	jmp	(r0)
31 | 
32 | cret:
33 | 	mov	r5,r1
34 | 	mov	-(r1),r4
35 | 	mov	-(r1),r3
36 | 	mov	-(r1),r2
37 | 	mov	r5,sp
38 | 	mov	(sp)+,r5
39 | 	rts	pc
40 | 
41 | 
42 | 
43 | 
44 | 
45 | 
46 | 
47 | 
48 | 
49 | 
50 | 
51 | 


--------------------------------------------------------------------------------
/usr/source/s/solloc/zero.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/salloc/zero.s
 3 | 

V6/usr/source/salloc/zero.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | .globl	zero
19 | .globl	putchar
20 | .globl	w, r, a, l
21 | /
22 | /
23 | /	routine to zero a string
24 | /
25 | /	mov	...,r1
26 | /	jsr	pc,zero
27 | /
28 | zero:
29 | 	mov	r0,-(sp)
30 | 	mov	a(r1),w(r1)
31 | 	clrb	r0
32 | 1:	cmp	w(r1),l(r1)
33 | 	bhis	1f
34 | 	jsr	pc,putchar
35 | 	br	1b
36 | 1:	mov	a(r1),w(r1)
37 | 	mov	(sp)+,r0
38 | 	rts	pc
39 | 
40 | 
41 | 
42 | 
43 | 
44 | 
45 | 
46 | 
47 | 
48 | 
49 | 
50 | 


--------------------------------------------------------------------------------
/usr/source/cref/src/put.c:
--------------------------------------------------------------------------------
 1 | int	bct[4];
 2 | int	optr[4];
 3 | char	bsp[2048];
 4 | 
 5 | char	*obuf[4]	{bsp,
 6 | 			bsp + 512,
 7 | 			bsp + 1024,
 8 | 			bsp + 1536
 9 | 			};
10 | 
11 | int	nflush;
12 | 
13 | put(fil,string,n)
14 | 	char	*string;
15 | {
16 | 	extern	utmp;
17 | 	int	i;
18 | 	char	*o;
19 | 
20 | /*printf("%d %c %d\n",fil,*string,n);/*DEBUG*/
21 | 
22 | 	string--;
23 | 
24 | 	if((i = optr[fil] + n - 512) >= 0) {
25 | 		n =- i;
26 | 		o = &obuf[fil][optr[fil]] -1;
27 | 		while(--n >= 0)
28 | 			*++o = *++string;
29 | 		optr[fil] = 512;
30 | 		flsh(fil);
31 | 		n = i;
32 | 	}
33 | 
34 | 	o = &obuf[fil][optr[fil]] - 1;
35 | 	optr[fil] =+ n;
36 | 
37 | 	while(--n >= 0) {
38 | 		*++o = *++string;
39 | 	}
40 | 	return(0);
41 | }
42 | 
43 | flsh(fil)
44 | {
45 | 	extern	tp[],utmp;
46 | 
47 | 	if(optr[fil] <= 0)	return(optr[fil]);
48 | 
49 | 	if(bct[fil]++ >= 128 && utmp == 0) {
50 | 		printf("Wraparound temp file %d\n",fil);
51 | 		dexit();
52 | 	}
53 | 	nflush++;
54 | 	if(write(tp[fil],obuf[fil],optr[fil]) != optr[fil])
55 | 		return(-1);
56 | 	optr[fil] = 0;
57 | 	return(0);
58 | }
59 | 
60 | 
61 | 
62 | 
63 | 
64 | 
65 | 
66 | 
67 | 
68 | 
69 | 
70 | 
71 | 


--------------------------------------------------------------------------------
/usr/source/cref/index/ecmn.h:
--------------------------------------------------------------------------------
 1 | int	count;
 2 | int	page;
 3 | struct	{
 4 | 		char	*beg;
 5 | 		int	ct;
 6 | 		char	term;
 7 | 	} temp[30];
 8 | 
 9 | int	pn;
10 | int	word;
11 | int	hsw;
12 | int	t1;
13 | 
14 | int	level;
15 | int	hlevel;
16 | int	dlevel;
17 | int	xtrn;
18 | 
19 | int	tp[2];
20 | 
21 | struct	{
22 | 		int	cl[NUMC];
23 | 	} tab[NUMS];
24 | 
25 | int	coll();
26 | int	save();
27 | int	out();
28 | int	hyphen();
29 | int	hyp1();
30 | int	hyp2();
31 | int	pno();
32 | int	error();
33 | 
34 | char	line[300];
35 | int	l;
36 | int	lno;
37 | char	c;
38 | int	cursl;
39 | char	curs[9];
40 | int	curfl;
41 | char	curf[10];
42 | 
43 | int	usw;
44 | int	xsw;
45 | int	only;
46 | int	cross;
47 | int	file;
48 | int	cs;
49 | int	(*flag[8])();
50 | int	fl;
51 | char	gch[8];
52 | 
53 | struct	htab	{
54 | 		int	hsiz;
55 | 		int	ssiz;
56 | 		int	nsym;
57 | 		int	curb;
58 | 		int	*hptr;
59 | 		char	*symt;
60 | 		};
61 | 
62 | struct	htab	itab;
63 | 
64 | int	ipsp[PTRI];
65 | char	issp[CHARI];
66 | 
67 | int	ib1[259];
68 | 
69 | char	*ibuf;
70 | char	*ibuf1;
71 | 
72 | char	mone;
73 | int	order;
74 | int	ssw;
75 | int	type;
76 | char	*utmp;
77 | 
78 | 
79 | 
80 | 
81 | 
82 | 
83 | 
84 | 
85 | 
86 | 
87 | 
88 | 


--------------------------------------------------------------------------------
/usr/source/s/s2/sleep.c:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s2/sleep.c
 3 | 

V6/usr/source/s2/sleep.c

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | main(argc, argv)
19 | char **argv;
20 | {
21 | 	int c, n;
22 | 	char *s;
23 | 
24 | 	n = 0;
25 | 	if(argc < 2) {
26 | 		printf("arg count\n");
27 | 		exit();
28 | 	}
29 | 	s = argv[1];
30 | 	while(c = *s++) {
31 | 		if(c<'0' || c>'9') {
32 | 			printf("bad character\n");
33 | 			exit();
34 | 		}
35 | 		n = n*10 + c - '0';
36 | 	}
37 | 	sleep(n);
38 | }
39 | 
40 | 
41 | 
42 | 
43 | 
44 | 
45 | 
46 | 
47 | 
48 | 
49 | 
50 | 


--------------------------------------------------------------------------------
/usr/source/s/s4/fcrt0.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s4/fcrt0.s
 3 | 

V6/usr/source/s4/fcrt0.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | / C runtime startoff
19 | / with floating point interpreter
20 | 
21 | .globl	savr5
22 | .globl	fptrap
23 | .globl	_exit
24 | 
25 | .globl	_main
26 | 
27 | start:
28 | 	sys	signal; 4; fptrap
29 | 	setd
30 | 	mov	sp,r0
31 | 	mov	(r0),-(sp)
32 | 	tst	(r0)+
33 | 	mov	r0,2(sp)
34 | 	jsr	pc,_main
35 | 	mov	r0,(sp)
36 | 	jsr	pc,*$_exit
37 | 	sys	exit
38 | 
39 | .bss
40 | savr5:	.=.+2
41 | 
42 | 
43 | 
44 | 
45 | 
46 | 
47 | 
48 | 
49 | 
50 | 
51 | 
52 | 


--------------------------------------------------------------------------------
/usr/sys/dmr/vt.c:
--------------------------------------------------------------------------------
 1 | /*
 2 |  * VT01 driver via DR11C to 11/20
 3 |  */
 4 |  
 5 | #include "../param.h"
 6 | #include "../user.h"
 7 |  
 8 | int	vtflag;
 9 |  
10 | struct vtreg {
11 | 	int	csr;
12 | 	int	buf;
13 | };
14 |  
15 | #define	VTADDR	0167770
16 | #define	RQINT	01
17 | #define	BIENABL	040
18 | #define	SEOF	0100000
19 | #define	VTPRI	8
20 |  
21 | vtopen(dev, flag)
22 | {
23 | 	if (!flag)
24 | 		u.u_error = ENXIO;
25 | 	else
26 | 		VTADDR->csr = BIENABL;
27 | }
28 |  
29 | vtclose()
30 | {
31 | 	VTADDR->buf = SEOF;
32 | 	VTADDR->csr =| RQINT;
33 | }
34 |  
35 | vtwrite()
36 | {
37 | 	register int c;
38 | 	int register count;
39 |  
40 | 	while ((c=cpass()) >= 0) {
41 | 	    retry:
42 | 		for (count=0; count<10; count++)
43 | 			if ((VTADDR->csr&RQINT)==0) {
44 | 				VTADDR->buf = c&0377;
45 | 				VTADDR->csr =| RQINT;
46 | 				goto contin;
47 | 			}
48 | 		spl5();
49 | 		if (VTADDR->csr&RQINT) {
50 | 			vtflag++;
51 | 			sleep(VTADDR, VTPRI);
52 | 		}
53 | 		spl0();
54 | 		goto retry;
55 |     contin:;
56 | 	}
57 | }
58 |  
59 | vtintr()
60 | {
61 | 	VTADDR->csr =& ~RQINT;
62 | 	if (vtflag) {
63 | 		vtflag = 0;
64 | 		wakeup(VTADDR);
65 | 	}
66 | }


--------------------------------------------------------------------------------
/usr/source/s/s4/atoi.c:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s4/atoi.c
 3 | 

V6/usr/source/s4/atoi.c

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | atoi(ap)
19 | char *ap;
20 | {
21 | 	register n, c;
22 | 	register char *p;
23 | 	int f;
24 | 
25 | 	p = ap;
26 | 	n = 0;
27 | 	f = 0;
28 | loop:
29 | 	while(*p == ' ' || *p == '	')
30 | 		p++;
31 | 	if(*p == '-') {
32 | 		f++;
33 | 		p++;
34 | 		goto loop;
35 | 	}
36 | 	while(*p >= '0' && *p <= '9')
37 | 		n = n*10 + *p++ - '0';
38 | 	if(f)
39 | 		n = -n;
40 | 	return(n);
41 | }
42 | 
43 | 
44 | 
45 | 
46 | 
47 | 
48 | 
49 | 
50 | 
51 | 
52 | 
53 | 


--------------------------------------------------------------------------------
/usr/source/s/solloc/bsp.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/salloc/bsp.s
 3 | 

V6/usr/source/salloc/bsp.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | .globl	backspace
19 | .globl	lookchar
20 | .globl	w, r, a, l
21 | /
22 | /	routine to read a string backwards
23 | /	the read pointer is decremented before reading
24 | /
25 | /	mov	...,r1
26 | /	jsr	pc,backspace
27 | /	mov	r0,...
28 | /
29 | backspace:
30 | 	cmp	a(r1),r(r1)
31 | 	bhis	nochc
32 | 	dec	r(r1)
33 | 	jsr	pc,lookchar
34 | 	rts	pc
35 | nochc:	clr	r0
36 | 	sec
37 | 	rts	pc
38 | 
39 | 
40 | 
41 | 
42 | 
43 | 
44 | 
45 | 
46 | 
47 | 
48 | 
49 | 


--------------------------------------------------------------------------------
/usr/sys/conf.h:
--------------------------------------------------------------------------------
 1 | /*
 2 |  * Used to dissect integer device code
 3 |  * into major (driver designation) and
 4 |  * minor (driver parameter) parts.
 5 |  */
 6 | struct
 7 | {
 8 | 	char	d_minor;
 9 | 	char	d_major;
10 | };
11 |  
12 | /*
13 |  * Declaration of block device
14 |  * switch. Each entry (row) is
15 |  * the only link between the
16 |  * main unix code and the driver.
17 |  * The initialization of the
18 |  * device switches is in the
19 |  * file conf.c.
20 |  */
21 | struct	bdevsw
22 | {
23 | 	int	(*d_open)();
24 | 	int	(*d_close)();
25 | 	int	(*d_strategy)();
26 | 	int	*d_tab;
27 | } bdevsw[];
28 |  
29 | /*
30 |  * Nblkdev is the number of entries
31 |  * (rows) in the block switch. It is
32 |  * set in binit/bio.c by making
33 |  * a pass over the switch.
34 |  * Used in bounds checking on major
35 |  * device numbers.
36 |  */
37 | int	nblkdev;
38 |  
39 | /*
40 |  * Character device switch.
41 |  */
42 | struct	cdevsw
43 | {
44 | 	int	(*d_open)();
45 | 	int	(*d_close)();
46 | 	int	(*d_read)();
47 | 	int	(*d_write)();
48 | 	int	(*d_sgtty)();
49 | } cdevsw[];
50 |  
51 | /*
52 |  * Number of character switch entries.
53 |  * Set by cinit/tty.c
54 |  */
55 | int	nchrdev;


--------------------------------------------------------------------------------
/usr/source/s/s3/rand.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s3/rand.s
 3 | 

V6/usr/source/s3/rand.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | / random fixed point number generator
19 | 
20 | .globl	rand, srand
21 | .globl	_rand, _srand
22 | 
23 | _srand:
24 | 	mov	2(sp),ranx
25 | 	rts	pc
26 | 
27 | srand:
28 | 	mov	r0,ranx
29 | 	rts	pc
30 | 
31 | _rand:
32 | rand:
33 | 	mov	r1,-(sp)
34 | 	mov	ranx,r1
35 | 	mpy	$13077.,r1
36 | 	add	$6925.,r1
37 | 	mov	r1,r0
38 | 	mov	r0,ranx
39 | 	bic	$100000,r0
40 | 	mov	(sp)+,r1
41 | 	rts	pc
42 | 
43 | .data
44 | ranx:	1
45 | 
46 | 
47 | 
48 | 
49 | 
50 | 
51 | 
52 | 
53 | 
54 | 
55 | 
56 | 


--------------------------------------------------------------------------------
/usr/source/s/sno/sno.h:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/sno/sno.h
 3 | 

V6/usr/source/sno/sno.h

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | struct	node {
19 | 	struct node *p1;
20 | 	struct node *p2;
21 | 	char typ;
22 | 	char ch;
23 | };
24 | 
25 | int	freesize;
26 | struct	node *lookf;
27 | struct	node *looks;
28 | struct	node *lookend;
29 | struct	node *lookstart;
30 | struct	node *lookdef;
31 | struct	node *lookret;
32 | struct	node *lookfret;
33 | int	cfail;
34 | int	rfail;
35 | struct	node *freelist;
36 | struct	node *namelist;
37 | int	lc;
38 | struct	node *schar;
39 | 
40 | 
41 | 
42 | 
43 | 
44 | 
45 | 
46 | 
47 | 
48 | 
49 | 
50 | 


--------------------------------------------------------------------------------
/usr/sys/dmr/cat.c:
--------------------------------------------------------------------------------
 1 | /*
 2 |  * GP DR11C driver used for C/A/T
 3 |  */
 4 |  
 5 | #include "../param.h"
 6 | #include "../user.h"
 7 | #include "../tty.h"
 8 |  
 9 | #define	CATADDR	0167750
10 | #define	PCAT	9
11 | #define	CATHIWAT	60
12 | #define	CATLOWAT	15
13 |  
14 | struct {
15 | 	int	catlock;
16 | 	struct	clist	oq;
17 | } cat;
18 |  
19 | struct {
20 | 	int	catcsr;
21 | 	int	catbuf;
22 | };
23 |  
24 | ctopen(dev)
25 | {
26 | 	if (cat.catlock==0) {
27 | 		cat.catlock++;
28 | 		CATADDR->catcsr =| IENABLE;
29 | 	} else
30 | 		u.u_error = ENXIO;
31 | }
32 |  
33 | ctclose()
34 | {
35 | 	cat.catlock = 0;
36 | }
37 |  
38 | ctwrite(dev)
39 | {
40 | 	register c;
41 | 	extern lbolt;
42 |  
43 | 	while ((c=cpass()) >= 0) {
44 | 		spl5();
45 | 		while (cat.oq.c_cc > CATHIWAT)
46 | 			sleep(&cat.oq, PCAT);
47 | 		while (putc(c, &cat.oq) < 0)
48 | 			sleep(&lbolt, PCAT);
49 | 		catintr();
50 | 		spl0();
51 | 	}
52 | }
53 |  
54 | catintr()
55 | {
56 | 	register int c;
57 |  
58 | 	if (CATADDR->catcsr&DONE && (c=getc(&cat.oq))>=0) {
59 | 		CATADDR->catbuf = c;
60 | 		if (cat.oq.c_cc==0 || cat.oq.c_cc==CATLOWAT)
61 | 			wakeup(&cat.oq);
62 | 	} else {
63 | 		if (cat.catlock==0)
64 | 			CATADDR->catcsr = 0;
65 | 	}
66 | }


--------------------------------------------------------------------------------
/usr/source/s/s7/run:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s7/run
 3 | 

V6/usr/source/s7/run

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | as suftab.s
19 | strip a.out
20 | cmp a.out /usr/lib/suftab
21 | cp a.out /usr/lib/suftab
22 | 
23 | as roff?.s
24 | ld -s a.out -l
25 | cmp a.out /usr/bin/roff
26 | cp a.out /usr/bin/roff
27 | 
28 | as nroff[1-5].s roff7.s nroff8.s
29 | ld -s -n a.out
30 | cmp a.out /usr/bin/nroff
31 | cp a.out /usr/bin/nroff
32 | 
33 | yacc ne.g
34 | cc -s -O -n ne*.c -ly
35 | cmp a.out /usr/bin/neqn
36 | cp a.out /usr/bin/neqn
37 | 
38 | rm y.tab.c *.o a.out
39 | 
40 | 
41 | 
42 | 
43 | 
44 | 
45 | 
46 | 
47 | 
48 | 
49 | 
50 | -------------------------------------------------------------------------------- /usr/source/s/s4/ltod.s: -------------------------------------------------------------------------------- 1 | 2 | V6/usr/source/s4/ltod.s 3 |

V6/usr/source/s4/ltod.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | / C library
19 | / return floating-point from long integer
20 | /	d = ltod(l)
21 | 
22 | .globl	_ltod
23 | _ltod:
24 | 	mov	r5,-(sp)
25 | 	mov	sp,r5
26 | 	setl
27 | 	movif	*4(r5),fr0
28 | 	seti
29 | 	mov	(sp)+,r5
30 | 	rts	pc
31 | 
32 | / return long integer from floating
33 | /	dtol(d, l)
34 | 
35 | .globl	_dtol
36 | _dtol:
37 | 	mov	r5,-(sp)
38 | 	mov	sp,r5
39 | 	setl
40 | 	movf	4(r5),fr0
41 | 	movfi	fr0,*12.(r5)
42 | 	seti
43 | 	mov	(sp)+,r5
44 | 	rts	pc
45 | 
46 | 
47 | 
48 | 
49 | 
50 | 
51 | 
52 | 
53 | 
54 | 
55 | 
56 | 


--------------------------------------------------------------------------------
/usr/source/s/s3/mesg.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s3/mesg.s
 3 | 

V6/usr/source/s3/mesg.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | .globl	mesg
19 | 
20 | / usage:
21 | /   jsr r5,mesg
22 | /       <string ending in \0>
23 | /      .even
24 | /   ...
25 | /
26 | / string is output onto $1
27 | /
28 | 
29 | mesg:
30 | 	mov	r0,-(sp)
31 | 	mov	r5,r0
32 | 	mov	r5,0f
33 | 1:
34 | 	tstb	(r5)+
35 | 	bne	1b
36 | 	sub	r5,r0
37 | 	com	r0
38 | 	mov	r0,0f+2
39 | 	mov	$1,r0
40 | 	sys	0; 9f
41 | .data
42 | 9:
43 | 	sys	write; 0:..; ..
44 | .text
45 | 	inc	r5
46 | 	bic	$1,r5
47 | 	mov	(sp)+,r0
48 | 	rts	r5
49 | 
50 | 
51 | 
52 | 
53 | 
54 | 
55 | 
56 | 
57 | 
58 | 
59 | 
60 | 
61 | 


--------------------------------------------------------------------------------
/usr/source/s/solloc/length.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/salloc/length.s
 3 | 

V6/usr/source/salloc/length.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | .globl	length
19 | .globl	position
20 | .globl	w, r, a, l
21 | /
22 | /
23 | /	routine to return the length of a string
24 | /
25 | /	mov	...,r1
26 | /	jsr	pc,length
27 | /	mov	r0,...
28 | /
29 | length:
30 | 	mov	w(r1),r0
31 | 	sub	a(r1),r0
32 | 	rts	pc
33 | /
34 | /
35 | /	routine to return the read pointer position
36 | /
37 | /	mov	...,r1
38 | /	jsr	pc,position
39 | /	mov	r0,...
40 | /
41 | position:
42 | 	mov	r(r1),r0
43 | 	sub	a(r1),r0
44 | 	rts	pc
45 | 
46 | 
47 | 
48 | 
49 | 
50 | 
51 | 
52 | 
53 | 
54 | 
55 | 
56 | 


--------------------------------------------------------------------------------
/usr/source/s/s3/fpx.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s3/fpx.s
 3 | 

V6/usr/source/s3/fpx.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | / fpx -- floating point simulation
19 | 
20 | .data
21 | reenter: 1
22 | 
23 | .bss
24 | asign:	.=.+2
25 | areg:	.=.+8
26 | aexp:	.=.+2
27 | bsign:	.=.+2
28 | breg:	.=.+8
29 | bexp:	.=.+2
30 | 
31 | fpsr:	.=.+2
32 | trapins: .=.+2
33 | 
34 | ac0:	.=.+8.
35 | ac1:	.=.+8.
36 | ac2:	.=.+8.
37 | ac3:	.=.+8.
38 | ac4:	.=.+8.
39 | ac5:	.=.+8.
40 | 
41 | sr0:	.=.+2
42 | sr1:	.=.+2
43 | 	.=.+2
44 | 	.=.+2
45 | 	.=.+2
46 | 	.=.+2
47 | ssp:	.=.+2
48 | spc:	.=.+2
49 | sps:	.=.+2
50 | pctmp:	.=.+8
51 | 
52 | 
53 | 
54 | 
55 | 
56 | 
57 | 
58 | 
59 | 
60 | 
61 | 
62 | 
63 | 


--------------------------------------------------------------------------------
/usr/sys/run:
--------------------------------------------------------------------------------
 1 | chdir ken
 2 | cc -c -O *.c
 3 | ar r ../lib1
 4 | rm *.o
 5 | 
 6 | chdir ../dmr
 7 | cc -c -O *.c
 8 | ar r ../lib2
 9 | rm *.o
10 | 
11 | chdir ../conf
12 | as m40.s
13 | mv a.out m40.o
14 | : as m45.s
15 | : mv a.out m45.o
16 | : cc sysfix.c
17 | : mv a.out sysfix
18 | cc mkconf.c
19 | mv a.out mkconf
20 | 
21 | mkconf
22 | rk
23 | tm
24 | tc
25 | done
26 | 
27 | cc -c c.c
28 | as l.s
29 | ld -x a.out m40.o c.o ../lib1 ../lib2
30 | : as data.s l.s
31 | : ld -x -r -d a.out m45.o c.o ../lib1 ../lib2
32 | : nm -ug
33 | : sysfix a.out x
34 | : mv x a.out
35 | cmp a.out /rkunix
36 | cp a.out /rkunix
37 | 
38 | mkconf
39 | rp
40 | tm
41 | tc
42 | done
43 | 
44 | cc -c c.c
45 | as l.s
46 | ld -x a.out m40.o c.o ../lib1 ../lib2
47 | : as data.s l.s
48 | : ld -x -r -d a.out m45.o c.o ../lib1 ../lib2
49 | : nm -ug
50 | : sysfix a.out x
51 | : mv x a.out
52 | cmp a.out /rpunix
53 | cp a.out /rpunix
54 | 
55 | mkconf
56 | hp
57 | tm
58 | tc
59 | done
60 | 
61 | cc -c c.c
62 | as l.s
63 | ld -x a.out m40.o c.o ../lib1 ../lib2
64 | : as data.s l.s
65 | : ld -x -r -d a.out m45.o c.o ../lib1 ../lib2
66 | : nm -ug
67 | : sysfix a.out x
68 | : mv x a.out
69 | cmp a.out /hpunix
70 | cp a.out /hpunix
71 | 
72 | rm mkconf c.c l.s a.out *.o
73 | : rm sysfix
74 | 


--------------------------------------------------------------------------------
/usr/source/s/s5/rin.c:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s5/rin.c
 3 | 

V6/usr/source/s5/rin.c

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | rin()
19 | {
20 | 	double d;
21 | 	register n, c, f;
22 | 
23 | 	d = 0.;
24 | 	f = 0;
25 | 	n = 0;
26 | loop:
27 | 	c = getchar();
28 | 	if(c == '\0')
29 | 		exit();
30 | 	if(c == '-') {
31 | 		f++;
32 | 		goto loop;
33 | 	}
34 | 	if(c == '.') {
35 | 		n++;
36 | 		goto loop;
37 | 	}
38 | 	if(c>='0' && c<='9') {
39 | 		if(n)
40 | 			n++;
41 | 		d = d*10.+c-'0';
42 | 		goto loop;
43 | 	}
44 | 	if(f)
45 | 		d = -d;
46 | 	for(f=1; f<n; f++)
47 | 		d =/ 10.;
48 | 	n = d;
49 | 	return(n);
50 | }
51 | 
52 | 
53 | 
54 | 
55 | 
56 | 
57 | 
58 | 
59 | 
60 | 
61 | 
62 | 


--------------------------------------------------------------------------------
/usr/source/cref/ccmn.h:
--------------------------------------------------------------------------------
 1 | struct	tempent {
 2 | 		char	*beg;
 3 | 		int	ct;
 4 | 		char	term;
 5 | 	} temp[30];
 6 | 
 7 | char	lbuf[5];
 8 | int	cflag;
 9 | int	t1;
10 | 
11 | int	level;
12 | int	hlevel;
13 | int	dlevel;
14 | int	xtrn;
15 | 
16 | int	tp[5];
17 | 
18 | struct	{
19 | 		int	cl[NUMC];
20 | 	} tab[NUMS];
21 | 
22 | int	coll();
23 | int	save();
24 | int	out();
25 | int	asym();
26 | int	asw();
27 | int	csym();
28 | int	csw();
29 | int	incl();
30 | int	decl();
31 | int	sk2();
32 | int	sk();
33 | int	tabs();
34 | int	semi();
35 | 
36 | char	line[132];
37 | int	l;
38 | int	lno;
39 | char	c;
40 | int	cursl;
41 | char	curs[9];
42 | int	curfl;
43 | char	curf[10];
44 | 
45 | int	usw;
46 | int	xsw;
47 | int	only;
48 | int	cross;
49 | int	file;
50 | int	cs;
51 | int	(*flag[8])();
52 | int	fl;
53 | char	gch[8];
54 | 
55 | struct	htab	{
56 | 		int	hsiz;
57 | 		int	ssiz;
58 | 		int	nsym;
59 | 		int	curb;
60 | 		int	*hptr;
61 | 		char	*symt;
62 | 		};
63 | 
64 | struct	htab	itab;
65 | struct	htab	xtab;
66 | 
67 | int	ipsp[PTRI];
68 | char	issp[CHARI];
69 | int	xpsp[PTRX];
70 | char	xssp[CHARX];
71 | 
72 | int	ib1[259];
73 | int	ib2[259];
74 | 
75 | char	*ibuf;
76 | char	*ibuf1;
77 | char	*ibuf2;
78 | 
79 | char	mone;
80 | int	order;
81 | int	ssw;
82 | int	type;
83 | char	*utmp;
84 | 
85 | 
86 | 
87 | 
88 | 
89 | 
90 | 
91 | 
92 | 
93 | 
94 | 
95 | 


--------------------------------------------------------------------------------
/usr/source/s/s1/chmod.c:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s1/chmod.c
 3 | 

V6/usr/source/s1/chmod.c

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | main(argc, argv)
19 | char **argv;
20 | {
21 | 	register i, m;
22 | 	register char *c;
23 | 	int count;
24 | 
25 | 	if(argc < 3) {
26 | 		printf("arg count\n");
27 | 		exit(1);
28 | 	}
29 | 	c = argv[1];
30 | 	m = 0;
31 | 	for(m=0; *c; c++) {
32 | 		if(*c < '0' || *c > '7') {
33 | 			printf("bad mode\n");
34 | 			exit(1);
35 | 		}
36 | 		m = (m<<3) | *c - '0';
37 | 	}
38 | 	for(i=2; i<argc; i++)
39 | 		if(chmod(argv[i], m) < 0) {
40 | 			count++;
41 | 			perror(argv[i]);
42 | 		}
43 | 	exit(count);
44 | }
45 | 
46 | 
47 | 
48 | 
49 | 
50 | 
51 | 
52 | 
53 | 
54 | 
55 | 
56 | 


--------------------------------------------------------------------------------
/usr/source/s/solloc/bword.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/salloc/bword.s
 3 | 

V6/usr/source/salloc/bword.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | .globl	backword
19 | .globl	lookchar
20 | .globl	w, r, a, l
21 | /
22 | /
23 | /	routine to get words backwards from string
24 | /
25 | /	mov	...,r1
26 | /	jsr	pc,backword
27 | /	mov	r0,...
28 | /
29 | backword:
30 | 	cmp	a(r1),r(r1)
31 | 	bhis	nochw
32 | 	dec	r(r1)
33 | 	jsr	pc,lookchar
34 | 	movb	r0,nchar+1
35 | 	cmp	a(r1),r(r1)
36 | 	bhis	nochw
37 | 	dec	r(r1)
38 | 	jsr	pc,lookchar
39 | 	movb	r0,nchar
40 | 	mov	nchar,r0
41 | 	rts	pc
42 | /
43 | nochw:
44 | 	clr	r0
45 | 	sec
46 | 	rts	pc
47 | /
48 | nchar:	.=.+2
49 | 
50 | 
51 | 
52 | 
53 | 
54 | 
55 | 
56 | 
57 | 
58 | 
59 | 
60 | 


--------------------------------------------------------------------------------
/usr/source/s/s3/floor.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s3/floor.s
 3 | 

V6/usr/source/s3/floor.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | .globl	_floor, _ceil
19 | .globl	floor, ceil
20 | one = 40200
21 | 
22 | _floor:
23 | 	mov	r5,-(sp)
24 | 	mov	sp,r5
25 | 	movf	4(r5),fr0
26 | 	jsr	pc,floor
27 | 	br	1f
28 | 
29 | _ceil:
30 | 	mov	r5,-(sp)
31 | 	mov	sp,r5
32 | 	movf	4(r5),fr0
33 | 	jsr	pc,ceil
34 | 1:
35 | 	mov	(sp)+,r5
36 | 	rts	pc
37 | 
38 | floor:
39 | 	tstf	fr0
40 | 	cfcc
41 | 	bge	1f
42 | 	modf	$one,fr0
43 | 	cfcc
44 | 	beq	2f
45 | 	subf	$one,fr1
46 | 	br	2f
47 | 1:
48 | 	modf	$one,fr0
49 | 2:
50 | 	movf	fr1,fr0
51 | 	rts	pc
52 | 
53 | ceil:
54 | 	negf	fr0
55 | 	jsr	pc,floor
56 | 	negf	fr0
57 | 	rts	pc
58 | 
59 | 
60 | 
61 | 
62 | 
63 | 
64 | 
65 | 
66 | 
67 | 
68 | 
69 | 


--------------------------------------------------------------------------------
/usr/source/s/s2/opr.c:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s2/opr.c
 3 | 

V6/usr/source/s2/opr.c

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | /*
19 |  *	opr -- off line print dispatcher
20 |  *		chooses spooling routine appropriate 
21 |  *		to destination
22 |  *
23 |  *	last entry in table isdefault
24 |  */
25 | 
26 | char *code[] {
27 | 	"-lp",	"/lib/lpr",	/* line printer */
28 | 	0
29 | };
30 | 
31 | main(argc, argv)
32 | char **argv;
33 | {
34 | 	int i, j;
35 | 
36 | 	argv[argc] = 0;
37 | 	for(i=0; code[i]; i=+2)
38 | 	if(argc > 1)
39 | 		for(j=0; code[i][j]==argv[1][j]; j++)
40 | 			if(code[i][j] == 0)
41 | 					execv(code[i+1], &argv[1]);
42 | 	execv(code[i-1], argv);
43 | 	write(2, "can't start daemon\n", 19);
44 | }
45 | 
46 | 
47 | 
48 | 
49 | 
50 | 
51 | 
52 | 
53 | 
54 | 
55 | 
56 | 


--------------------------------------------------------------------------------
/usr/source/s/s4/getc.s:
--------------------------------------------------------------------------------
 1 | / getw/getc -- get words/characters from input file
 2 | / fopen -- open a file for use by get(c|w)
 3 | 
 4 | indir = 0
 5 | 
 6 | .globl	_getc, _getw, _fopen
 7 | .globl	cerror
 8 | .comm	_errno,2
 9 | 
10 | _fopen:
11 | 	mov	r5,-(sp)
12 | 	mov	sp,r5
13 | 	mov	4(r5),0f
14 | 	sys	0; 9f
15 | 	.data
16 | 9:	sys	open; 0:..; 0
17 | 	.text
18 | 	bes	badret
19 | 	mov	6(r5),r1
20 | 	mov	r0,(r1)+
21 | 	clr	(r1)+
22 | 	clr	r0
23 | 	mov	(sp)+,r5
24 | 	rts	pc
25 | 
26 | _getw:
27 | 	clr	_errno
28 | 	mov	r5,-(sp)
29 | 	mov	sp,r5
30 | 	mov	4(r5),r1
31 | 	sub	$2,2(r1)
32 | 	bge	1f
33 | 	cmp	2(r1),$-1
34 | 	blt	2f
35 | 	movb	*4(r1),-(sp)
36 | 	jsr	pc,fill
37 | 	mov	4(r1),r0
38 | 	br	3f
39 | 2:
40 | 	jsr	pc,fill
41 | 	dec	2(r1)
42 | 1:
43 | 	mov	4(r1),r0
44 | 	movb	(r0)+,-(sp)
45 | 3:
46 | 	movb	(r0)+,1(sp)
47 | 	mov	r0,4(r1)
48 | 	mov	(sp)+,r0
49 | 	mov	(sp)+,r5
50 | 	rts	pc
51 | 
52 | _getc:
53 | 	mov	r5,-(sp)
54 | 	mov	sp,r5
55 | 	mov	4(r5),r1
56 | 	dec	2(r1)
57 | 	bge	1f
58 | 	jsr	pc,fill
59 | 1:
60 | 	clr	r0
61 | 	bisb	*4(r1),r0
62 | 	inc	4(r1)
63 | 	mov	(sp)+,r5
64 | 	rts	pc
65 | 
66 | fill:
67 | 	mov	r1,r0
68 | 	add	$6,r0
69 | 	mov	r0,0f
70 | 	mov	r0,4(r1)
71 | 	mov	(r1),r0
72 | 	sys	0; 9f
73 | .data
74 | 9:	sys	read; 0:..; 512.
75 | .text
76 | 	bes	badret
77 | 	dec	r0
78 | 	bmi	badret
79 | 	mov	r0,2(r1)
80 | 	rts	pc
81 | 
82 | badret:
83 | 	jmp	cerror
84 | 
85 | 
86 | 
87 | 
88 | 
89 | 
90 | 
91 | 
92 | 
93 | 
94 | 
95 | 


--------------------------------------------------------------------------------
/usr/source/s/s4/ladd.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s4/ladd.s
 3 | 

V6/usr/source/s4/ladd.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | / C routine-- long integer subtract and add
19 | 
20 | / ladd/lsub (a, b, c);
21 | /	int a[2], b[2], c[2];
22 | /	a = b +- c;
23 | 
24 | .globl	_lsub
25 | .globl	_ladd
26 | .globl	csv
27 | .globl	cret
28 | 
29 | _lsub:
30 | 	jsr	r5,csv
31 | 	mov	6(r5),r2
32 | 	mov	(r2)+,r0
33 | 	mov	(r2),r1
34 | 	mov	10(r5),r2
35 | 	sub	(r2)+,r0
36 | 	sub	(r2),r1
37 | 	sbc	r0
38 | 	mov	4(r5),r2
39 | 	mov	r0,(r2)+
40 | 	mov	r1,(r2)
41 | 	jmp	cret
42 | 
43 | _ladd:
44 | 	jsr	r5,csv
45 | 	mov	6(r5),r2
46 | 	mov	(r2)+,r0
47 | 	mov	(r2),r1
48 | 	mov	10(r5),r2
49 | 	add	(r2)+,r0
50 | 	add	(r2),r1
51 | 	adc	r0
52 | 	mov	4(r5),r2
53 | 	mov	r0,(r2)+
54 | 	mov	r1,(r2)
55 | 	jmp	cret
56 | 
57 | 
58 | 
59 | 
60 | 
61 | 
62 | 
63 | 
64 | 
65 | 
66 | 
67 | 


--------------------------------------------------------------------------------
/usr/source/s/solloc/rewind.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/salloc/rewind.s
 3 | 

V6/usr/source/salloc/rewind.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | .globl	rewind
19 | .globl	create
20 | .globl	fsfile
21 | .globl	w, r, a, l
22 | /
23 | /
24 | /	routine to rewind read pointer of string
25 | /	pointed to by r1
26 | /
27 | /	mov	...,r1
28 | /	jsr	pc,rewind
29 | /
30 | rewind:
31 | 	mov	a(r1),r(r1)
32 | 	rts	pc
33 | /
34 | /	routine to rewind write pointer of string
35 | /	pointed to by r1
36 | /
37 | /	mov	...,r1
38 | /	jsr	pc,create
39 | /
40 | create:
41 | 	mov	a(r1),w(r1)
42 | 	mov	a(r1),r(r1)
43 | 	rts	pc
44 | /
45 | /
46 | /	routine to copy read pointer of string to end of string
47 | /
48 | /	mov	...,r1
49 | /	jsr	pc,fsfile
50 | /
51 | fsfile:
52 | 	mov	w(r1),r(r1)
53 | 	rts	pc
54 | 
55 | 
56 | 
57 | 
58 | 
59 | 
60 | 
61 | 
62 | 
63 | 
64 | 
65 | 


--------------------------------------------------------------------------------
/usr/source/s/s2/rew.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s2/rew.s
 3 | 

V6/usr/source/s2/rew.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | / rew -- rewind dec/mag tape
19 | 
20 | 	cmp	(sp)+,$2
21 | 	blt	1f
22 | 	tst	(sp)+
23 | 	mov	(sp)+,r0
24 | 	movb	(r0)+,r1
25 | 	cmp	r1,$'m
26 | 	beq	rewm
27 | 	movb	r1,tapx+8
28 | 	tstb	(r0)
29 | 	bne	error
30 | 1:
31 | 	sys	open; tapx; 0
32 | 	br	rew
33 | 
34 | rewm:
35 | 	movb	(r0)+,r1
36 | 	beq	1f
37 | 	movb	r1,mtx+7
38 | 	tstb	(r0)
39 | 	bne	error
40 | 1:
41 | 	sys	open; mtx; 0
42 | 
43 | rew:
44 | 	bes	error
45 | 	sys	read; word; 2
46 | 	bes	error
47 | 	sys	exit
48 | 
49 | error:
50 | 	mov	$1,r0
51 | 	sys	write; 0f; 2
52 | 	sys	exit
53 | 0:
54 | 	<?\n>
55 | 
56 | tapx:
57 | 	</dev/tap0\0>
58 | mtx:
59 | 	</dev/mt0\0>
60 | 	.even
61 | 
62 | .bss
63 | word:	.=.+2
64 | 
65 | 
66 | 
67 | 
68 | 
69 | 
70 | 
71 | 
72 | 
73 | 
74 | 
75 | 
76 | 


--------------------------------------------------------------------------------
/usr/source/s/s3/switch.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s3/switch.s
 3 | 

V6/usr/source/s3/switch.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | / switch -- switch on contents of r0
19 | /
20 | /
21 | / calling sequence --
22 | /
23 | /   jsr r5,switch; swtab
24 | /
25 | / r0 is looked up in swtab and if found
26 | / control is returned to the corresponding place
27 | / if r0 is not found, the next inline instruction is 
28 | / executed
29 | /
30 | / swtab format --
31 | /
32 | / swtab:
33 | /    val1; ret1
34 | /   val2; ret2
35 | /   ...
36 | /   valn; retn
37 | /   ..; 0
38 | /
39 | 
40 | 	.globl	switch
41 | switch:
42 | 	mov	r1,-(sp)
43 | 	mov	(r5)+,r1
44 | 1:
45 | 	cmp	r0,(r1)+
46 | 	beq	1f
47 | 	tst	(r1)+
48 | 	bne	1b
49 | 2:
50 | 	mov	(sp)+,r1
51 | 	rts	r5
52 | 1:
53 | 	mov	(r1)+,r1
54 | 	beq	2b
55 | 	mov	r1,r5
56 | 	br	2b
57 | 
58 | 
59 | 
60 | 
61 | 
62 | 
63 | 
64 | 
65 | 
66 | 
67 | 
68 | 
69 | 


--------------------------------------------------------------------------------
/usr/source/s/s2/nohup.c:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s2/nohup.c
 3 | 

V6/usr/source/s2/nohup.c

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | /* nohup */
19 | char	*args[100];
20 | char	string[10000];
21 | 
22 | main(argc, argv)
23 | int argc;
24 | char *argv[];
25 | {
26 | 	int i;
27 | 	char **argp, *strp, *p;
28 | 
29 | 	if(argc < 2) {
30 | 		printf("arg count\n");
31 | 		exit();
32 | 	}
33 | 	argc--;
34 | 	argv++;
35 | 	argp = args;
36 | 	strp = string;
37 | 	for (i=0; i<9; i++)
38 | 		*strp++ = "/usr/bin/"[i];
39 | 	for(i=0; i<argc; i++) {
40 | 		*argp++ = strp;
41 | 		p = *argv++;
42 | 		while(*strp++ = *p++);
43 | 	}
44 | 	*argp = 0;
45 | 	signal(1, 1);
46 | 	signal(2, 1);
47 | 	signal(3, 1);
48 | 	execv(string+9, args);
49 | 	execv(string+4, args);
50 | 	execv(string, args);
51 | 	printf("%s not found\n", string+9);
52 | }
53 | 
54 | 
55 | 
56 | 
57 | 
58 | 
59 | 
60 | 
61 | 
62 | 
63 | 
64 | 


--------------------------------------------------------------------------------
/usr/source/s/s5/perror.c:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s5/perror.c
 3 | 

V6/usr/source/s5/perror.c

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | /*
19 |  * Print the error indicated
20 |  * in the cerror cell.
21 |  */
22 | 
23 | int	errno;
24 | int	sys_nerr;
25 | char	*sys_errlist[];
26 | perror(s)
27 | char *s;
28 | {
29 | 	register char *c;
30 | 	register n;
31 | 
32 | 	c = "Unknown error";
33 | 	if(errno < sys_nerr)
34 | 		c = sys_errlist[errno];
35 | 	n = strlen(s);
36 | 	if(n) {
37 | 		write(2, s, n);
38 | 		write(2, ": ", 2);
39 | 	}
40 | 	write(2, c, strlen(c));
41 | 	write(2, "\n", 1);
42 | }
43 | 
44 | /*
45 |  * Return the number of bytes in a string
46 |  */
47 | 
48 | strlen(str)
49 | char *str;
50 | {
51 | 	register char *s;
52 | 
53 | 	s = str;
54 | 	while(*s++)
55 | 		;
56 | 	return(s-str-1);
57 | }
58 | //NEXEC
59 | 
60 | 
61 | 
62 | 
63 | 
64 | 
65 | 
66 | 
67 | 
68 | 
69 | 
70 | 
71 | 


--------------------------------------------------------------------------------
/usr/source/s/s3/run:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s3/run
 3 | 

V6/usr/source/s3/run

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | as atan.s; mv a.out atan.o
19 | as crypt.s; mv a.out crypt.o
20 | as dpadd.s; mv a.out dpadd.o
21 | as ecvt.s; mv a.out ecvt.o
22 | as exp.s; mv a.out exp.o
23 | as floor.s; mv a.out floor.o
24 | as fmod.s; mv a.out fmod.o
25 | as fp?.s; mv a.out fp.o
26 | : as fakfp.s: mv a.out fp.o
27 | as gamma.s; mv a.out gamma.o
28 | as get.s; mv a.out get.o
29 | as ldiv.s; mv a.out ldiv.o
30 | as log.s; mv a.out log.o
31 | as mesg.s; mv a.out mesg.o
32 | as pow.s; mv a.out pow.o
33 | as put.s; mv a.out put.o
34 | as rand.s; mv a.out rand.o
35 | as savr5.s; mv a.out savr5.o
36 | as sin.s; mv a.out sin.o
37 | as sqrt.s; mv a.out sqrt.o
38 | as switch.s; mv a.out switch.o
39 | as ttyn.s; mv a.out ttyn.o
40 | ar r /lib/liba.a
41 | rm *.o
42 | 
43 | 
44 | 
45 | 
46 | 
47 | 
48 | 
49 | 
50 | 
51 | 
52 | 
53 | -------------------------------------------------------------------------------- /usr/source/s/s2/pfe.s: -------------------------------------------------------------------------------- 1 | 2 | V6/usr/source/s2/pfe.s 3 |

V6/usr/source/s2/pfe.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | / print last floating error
19 | 
20 | stst	= 170300^tst
21 | 
22 | 	stst	r1
23 | 	cmp	r1,$14
24 | 	blos	1f
25 | 	clr	r1
26 | 1:
27 | 	bic	$1,r1
28 | 	mov	mesg(r1),r1
29 | 1:
30 | 	movb	(r1)+,ch
31 | 	beq	1f
32 | 	mov	$1,r0
33 | 	sys	write; ch; 1
34 | 	br	1b
35 | 1:
36 | 	sys	exit
37 | 
38 | mesg:
39 | 	1f
40 | 	2f
41 | 	3f
42 | 	4f
43 | 	5f
44 | 	6f
45 | 	7f
46 | 	8f
47 | 
48 | 1:	<No error.\n\0>
49 | 2:	<Floating op code error\n\0>
50 | 3:	<Floating divide check\n\0>
51 | 4:	<Integer conversion error\n\0>
52 | 5:	<Floating overflow\n\0>
53 | 6:	<Floating underflow\n\0>
54 | 7:	<Floating undefined\n\0>
55 | 8:	<Floating maintennace trap\n\0>
56 | 
57 | 	.even
58 | 
59 | 	.bss
60 | ch:	.=.+2
61 | 
62 | 
63 | 
64 | 
65 | 
66 | 
67 | 
68 | 
69 | 
70 | 
71 | 
72 | 
73 | 


--------------------------------------------------------------------------------
/usr/source/s/s7/ne5.c:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s7/ne5.c
 3 | 

V6/usr/source/s7/ne5.c

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | #include "ne.h"
19 | 
20 | int	markpos;
21 | 
22 | mark(n) int n; {
23 | 	if( n )
24 | 		markpos = ewid[n];
25 | 	else {
26 | 		yyval = oalloc();
27 | 		printf(".ds %d \"\n", yyval);
28 | 		ebase[yyval] = ewid[yyval] = markpos = 0;
29 | 		eht[yyval] = 2;
30 | 	}
31 | 	if(dbg)printf(".\tmark %d as %d\n", n, markpos);
32 | }
33 | 
34 | lineup(n) int n; {
35 | 	if( n ) {
36 | 		printf(".ds %d \"", n);
37 | 		fwd(markpos-ewid[n]);
38 | 		printf("\\*(%d\n", n);
39 | 		ewid[n] = markpos;
40 | 	}
41 | 	else {
42 | 		yyval = oalloc();
43 | 		printf(".ds %d \"", yyval);
44 | 		fwd(markpos);
45 | 		printf("\n");
46 | 		ebase[yyval] = 0;
47 | 		eht[yyval] = 2;
48 | 		ewid[yyval] = markpos;
49 | 	}
50 | 	if(dbg)printf(".\tlineup %d at %d\n", n, markpos);
51 | }
52 | 
53 | 
54 | 
55 | 
56 | 
57 | 
58 | 
59 | 
60 | 
61 | 
62 | 
63 | 


--------------------------------------------------------------------------------
/usr/source/s/s7/ne.h:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s7/ne.h
 3 | 

V6/usr/source/s7/ne.h

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | #
19 | int	dbg;
20 | int	ct;
21 | int	lp[40];
22 | char	used[100];	/* available registers */
23 | int	ps;	/* dflt init pt size */
24 | int	ft;	/* dflt font */
25 | int	first;
26 | extern	int	fout, fin;
27 | int	ifile;
28 | int	linect;	/* line number in file */
29 | int	eqline;	/* line where eqn started */
30 | int	svargc;
31 | char	**svargv;
32 | int	eht[100];
33 | int	ebase[100];
34 | int	ewid[100];
35 | struct { char c1; char c2; };
36 | int	yyval;
37 | int	*yypv;
38 | int	yylval;
39 | int	tht[30];
40 | int	tbase[30];
41 | int	ptr;
42 | char	*nptr[50];
43 | char *sptr[50];
44 | int	eqnreg, eqnht, eqnbase;
45 | int	lefteq, righteq;
46 | int	lastchar;	/* last character read by lex */
47 | #define	FATAL	1
48 | int	ESC;
49 | int	HREV;
50 | int	HFWD;
51 | int	SI;
52 | int	SO;
53 | 
54 | 
55 | 
56 | 
57 | 
58 | 
59 | 
60 | 
61 | 
62 | 
63 | 
64 | 


--------------------------------------------------------------------------------
/usr/source/s/s2/mount.c:
--------------------------------------------------------------------------------
 1 | #define	NMOUNT	16
 2 | #define	NAMSIZ	32
 3 | 
 4 | struct mtab {
 5 | 	char	file[NAMSIZ];
 6 | 	char	spec[NAMSIZ];
 7 | } mtab[NMOUNT];
 8 | 
 9 | main(argc, argv)
10 | char **argv;
11 | {
12 | 	register int ro;
13 | 	register struct mtab *mp;
14 | 	register char *np;
15 | 	int n, mf;
16 | 
17 | 	mf = open("/etc/mtab", 0);
18 | 	read(mf, mtab, NMOUNT*2*NAMSIZ);
19 | 	if (argc==1) {
20 | 		for (mp = mtab; mp < &mtab[NMOUNT]; mp++)
21 | 			if (mp->file[0])
22 | 				printf("%s on %s\n", mp->spec, mp->file);
23 | 		return;
24 | 	}
25 | 	if(argc < 3) {
26 | 		printf("arg count\n");
27 | 		return;
28 | 	}
29 | 	ro = 0;
30 | 	if(argc > 3)
31 | 		ro++;
32 | 	if(mount(argv[1], argv[2], ro) < 0) {
33 | 		perror("mount");
34 | 		return;
35 | 	}
36 | 	np = argv[1];
37 | 	while(*np++)
38 | 		;
39 | 	np--;
40 | 	while(*--np == '/')
41 | 		*np = '\0';
42 | 	while(np > argv[1] && *--np != '/')
43 | 		;
44 | 	if(*np == '/')
45 | 		np++;
46 | 	argv[1] = np;//smount
47 | 	for (mp = mtab; mp < &mtab[NMOUNT]; mp++) {
48 | 		if (mp->file[0] == 0) {
49 | 			for (np = mp->spec; np < &mp->spec[NAMSIZ-1];)
50 | 				if ((*np++ = *argv[1]++) == 0)
51 | 					argv[1]--;
52 | 			for (np = mp->file; np < &mp->file[NAMSIZ-1];)
53 | 				if ((*np++ = *argv[2]++) == 0)
54 | 					argv[2]--;
55 | 			mp = &mtab[NMOUNT];
56 | 			while ((--mp)->file[0] == 0);
57 | 			mf = creat("/etc/mtab", 0644);
58 | 			write(mf, mtab, (mp-mtab+1)*2*NAMSIZ);
59 | 			return;
60 | 		}
61 | 	}
62 | }
63 | 
64 | 
65 | 
66 | 
67 | 
68 | 
69 | 
70 | 
71 | 
72 | 
73 | 
74 | 


--------------------------------------------------------------------------------
/usr/source/s/s5/putc.s:
--------------------------------------------------------------------------------
  1 | / putw/putc -- write words/characters on output file
  2 | 
  3 | 	.globl	_putc, _putw, _fflush, _fcreat
  4 | 	.globl cerror
  5 | 	.comm	_errno,2
  6 | 
  7 | _fcreat:
  8 | 	mov	r5,-(sp)
  9 | 	mov	sp,r5
 10 | 	mov	4(r5),0f
 11 | 	mov	6(r5),r1
 12 | 	mov	pc,(r1)		/ a putatively illegal file desc.
 13 | 	sys	0; 9f
 14 | .data
 15 | 9:	sys	creat; 0:..; 666
 16 | .text
 17 | 	bes	badret
 18 | 	mov	r0,(r1)+
 19 | 	clr	(r1)+
 20 | 	clr	(r1)+
 21 | 	br	goodret
 22 | 
 23 | _putw:
 24 | 	mov	r5,-(sp)
 25 | 	mov	sp,r5
 26 | 	mov	6(r5),r1
 27 | 	dec	2(r1)
 28 | 	bge	1f
 29 | 	jsr	pc,fl
 30 | 	dec	2(r1)
 31 | 1:
 32 | 	movb	4(r5),*4(r1)
 33 | 	inc	4(r1)
 34 | 	dec	2(r1)
 35 | 	bge	1f
 36 | 	jsr	pc,fl
 37 | 	dec	2(r1)
 38 | 1:
 39 | 	movb	5(r5),*4(r1)
 40 | 	inc	4(r1)
 41 | 	mov	4(r5),r0
 42 | 	br	goodret
 43 | 
 44 | _putc:
 45 | 	mov	r5,-(sp)
 46 | 	mov	sp,r5
 47 | 	mov	6(r5),r1
 48 | 	dec	2(r1)
 49 | 	bge	1f
 50 | 	jsr	pc,fl
 51 | 	dec	2(r1)
 52 | 1:
 53 | 	mov	4(r5),r0
 54 | 	movb	r0,*4(r1)
 55 | 	inc	4(r1)
 56 | 	br	goodret
 57 | 
 58 | _fflush:
 59 | 	mov	r5,-(sp)
 60 | 	mov	sp,r5
 61 | 	mov	4(r5),r1
 62 | 	jsr	pc,fl
 63 | 	br	goodret
 64 | 
 65 | fl:
 66 | 	mov	r1,r0
 67 | 	add	$6,r0
 68 | 	mov	r0,-(sp)
 69 | 	mov	r0,0f
 70 | 	mov	4(r1),0f+2
 71 | 	beq	1f
 72 | 	sub	r0,0f+2
 73 | 	mov	(r1),r0
 74 | 	sys	0; 9f
 75 | .data
 76 | 9:	sys	write; 0:..; ..
 77 | .text
 78 | 1:
 79 | 	mov	(sp)+,4(r1)
 80 | 	mov	$512.,2(r1)
 81 | 	rts	pc
 82 | 
 83 | badret:
 84 | 	jmp	cerror
 85 | 
 86 | goodret:
 87 | 	clr	_errno
 88 | 	mov	(sp)+,r5
 89 | 	rts	pc
 90 | 
 91 | 
 92 | 
 93 | 
 94 | 
 95 | 
 96 | 
 97 | 
 98 | 
 99 | 
100 | 
101 | 


--------------------------------------------------------------------------------
/usr/source/s/s4/getpw.c:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s4/getpw.c
 3 | 

V6/usr/source/s4/getpw.c

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | getpw(uid, buf)
19 | int uid;
20 | char buf[];
21 | {
22 | 	auto pbuf[259];
23 | 	static pwf;
24 | 	register n, c;
25 | 	register char *bp;
26 | 
27 | 	if(pwf == 0)
28 | 		pwf = open("/etc/passwd", 0);
29 | 	if(pwf < 0)
30 | 		return(1);
31 | 	seek(pwf, 0, 0);
32 | 	pbuf[0] = pwf;
33 | 	pbuf[1] = 0;
34 | 	pbuf[2] = 0;
35 | 	uid =& 0377;
36 | 
37 | 	for (;;) {
38 | 		bp = buf;
39 | 		while((c=getc(pbuf)) != '\n') {
40 | 			if(c <= 0)
41 | 				return(1);
42 | 			*bp++ = c;
43 | 		}
44 | 		*bp++ = '\0';
45 | 		bp = buf;
46 | 		n = 3;
47 | 		while(--n)
48 | 		while((c = *bp++) != ':')
49 | 			if(c == '\n')
50 | 				return(1);
51 | 		while((c = *bp++) != ':') {
52 | 			if(c<'0' || c>'9')
53 | 				continue;
54 | 			n = n*10+c-'0';
55 | 		}
56 | 		if(n == uid)
57 | 			return(0);
58 | 	}
59 | 	return(1);
60 | }
61 | 
62 | 
63 | 
64 | 
65 | 
66 | 
67 | 
68 | 
69 | 
70 | 
71 | 
72 | 


--------------------------------------------------------------------------------
/usr/source/s/s4/locv.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s4/locv.s
 3 | 

V6/usr/source/s4/locv.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | / C library -- long output conversion
19 | 
20 | .globl	_locv
21 | 
22 | _locv:
23 | 	mov	r5,-(sp)
24 | 	mov	sp,r5
25 | 	mov	r4,-(sp)
26 | 	mov	r3,-(sp)
27 | 	mov	r2,-(sp)
28 | 	mov	$buf,r4
29 | 	mov	6(r5),r3
30 | 	mov	4(r5),r2
31 | 	bpl	1f
32 | 	neg	r2
33 | 	neg	r3
34 | 	sbc	r2
35 | 	movb	$'-,(r4)+
36 | 1:
37 | 	jsr	pc,1f
38 | 	clrb	(r4)+
39 | 	mov	$buf,r0
40 | 	mov	(sp)+,r2
41 | 	mov	(sp)+,r3
42 | 	mov	(sp)+,r4
43 | 	mov	(sp)+,r5
44 | 	rts	pc
45 | 
46 | 1:
47 | 	jsr	pc,divid
48 | 	add	$'0,r1
49 | 	mov	r1,-(sp)
50 | 	ashc	$0,r2
51 | 	beq	1f
52 | 	jsr	pc,1b
53 | 1:
54 | 	movb	(sp)+,(r4)+
55 | 	rts	pc
56 | 
57 | divid:
58 | 	clr	r1
59 | 	mov	$32.,r0
60 | 1:
61 | 	ashc	$1,r2
62 | 	rol	r1
63 | 	cmp	r1,$10.
64 | 	blo	2f
65 | 	sub	$10.,r1
66 | 	inc	r3
67 | 2:
68 | 	sob	r0,1b
69 | 	rts	pc
70 | 
71 | 
72 | .bss
73 | buf:	.=.+12.
74 | 
75 | 
76 | 
77 | 
78 | 
79 | 
80 | 
81 | 
82 | 
83 | 
84 | 
85 | 


--------------------------------------------------------------------------------
/usr/source/s/s3/pow.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s3/pow.s
 3 | 

V6/usr/source/s3/pow.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | .globl	pow, _pow
19 | .globl	log, exp
20 | 
21 | _pow:
22 | 	mov	r5,-(sp)
23 | 	mov	sp,r5
24 | 	movf	4(r5),fr0
25 | 	movf	12.(r5),fr1
26 | 	jsr	pc,pow
27 | 	mov	(sp)+,r5
28 | 	rts	pc
29 | 
30 | pow:
31 | 
32 | / 0^0~ is 0
33 | 
34 | 	tstf	fr0
35 | 	cfcc
36 | 	bne	1f
37 | 	tstf	fr1
38 | 	cfcc
39 | 	beq	bad
40 | 	rts	pc
41 | 1:
42 | 
43 | / -^i is +^i fixed sign
44 | 
45 | 	bpl	1f
46 | 	movf	fr1,-(sp)
47 | 	modf	$one,fr1
48 | 	cfcc
49 | 	bne	bad1
50 | 	movf	(sp)+,fr1
51 | 	absf	fr0
52 | 	jsr	pc,1f
53 | 	bes	bad
54 | 	movf	fr1,-(sp)
55 | 	modf	$half,fr1
56 | 	cfcc
57 | 	beq	2f
58 | 	negf	fr0
59 | 2:
60 | 	movf	(sp)+,fr1
61 | 	rts	pc
62 | 1:
63 | 	jsr	pc,log
64 | 	bes	1f
65 | 	mulf	 fr1,fr0
66 | 	jsr	pc,exp
67 | 1:
68 | 	rts	pc
69 | 
70 | bad1:
71 | 	movf	(sp)+,fr1
72 | bad:
73 | 	sec
74 | 	rts	pc
75 | 
76 | one = 40200
77 | half = 40000
78 | 
79 | 
80 | 
81 | 
82 | 
83 | 
84 | 
85 | 
86 | 
87 | 
88 | 
89 | 


--------------------------------------------------------------------------------
/usr/source/s/s2/nice.c:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s2/nice.c
 3 | 

V6/usr/source/s2/nice.c

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | /* nice */
19 | int	nicarg	4;
20 | char	*args[100];
21 | char	string[10000];
22 | 
23 | main(argc, argv)
24 | int argc;
25 | char *argv[];
26 | {
27 | 	int i;
28 | 	register char **argp, *strp, *p;
29 | 
30 | 	if(argc > 1 && argv[1][0] == '-') {
31 | 		nicarg = atoi(&argv[1][1]);
32 | 		argc--;
33 | 		argv++;
34 | 	}
35 | 	if(argc < 2) {
36 | 		printf("usage: nice [ -n ] command\n");
37 | 		exit(1);
38 | 	}
39 | 	argc--;
40 | 	argv++;
41 | 	argp = args;
42 | 	strp = string;
43 | 	for (i=0; i<9; i++)
44 | 		*strp++ = "/usr/bin/"[i];
45 | 	for(i=0; i<argc; i++) {
46 | 		*argp++ = strp;
47 | 		p = *argv++;
48 | 		while(*strp++ = *p++);
49 | 	}
50 | 	*argp = 0;
51 | 	nice(nicarg);
52 | 	execv(string+9, args);
53 | 	execv(string+4, args);
54 | 	execv(string, args);
55 | 	printf("%s not found\n", string+9);
56 | 	exit(1);
57 | }
58 | 
59 | 
60 | 
61 | 
62 | 
63 | 
64 | 
65 | 
66 | 
67 | 
68 | 
69 | 


--------------------------------------------------------------------------------
/usr/source/s/s5/putchr.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s5/putchr.s
 3 | 

V6/usr/source/s5/putchr.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | / C library -- putchar
19 | 
20 | 	.globl	_putchar,_flush
21 | 	.globl	_fout
22 | 
23 | _putchar:
24 | 	mov	r5,-(sp)
25 | 	mov	sp,r5
26 | 	mov	_fout+4,r0
27 | 	bne	1f
28 | 	jsr	pc,fl
29 | 	mov	_fout+4,r0
30 | 1:
31 | 	movb	4(r5),(r0)+
32 | 	beq	1f
33 | 	inc	_fout+4
34 | 	dec	_fout+2
35 | 	bgt	1f
36 | 	jsr	pc,fl
37 | 1:
38 | 	mov	4(r5),r0
39 | 	mov	(sp)+,r5
40 | 	rts	pc
41 | 
42 | _flush:
43 | 	mov	r5,-(sp)
44 | 	mov	sp,r5
45 | 	jsr	pc,fl
46 | 	mov	(sp)+,r5
47 | 	rts	pc
48 | 
49 | fl:
50 | 	mov	_fout+4,r0
51 | 	beq	1f
52 | 	sub	$_fout+6,r0
53 | 	mov	r0,0f
54 | 	mov	_fout,r0
55 | 	bne	2f
56 | 	inc	r0
57 | 2:
58 | 	sys	0; 9f
59 | .data
60 | 9:	sys	write; _fout+6; 0:..
61 | .text
62 | 1:
63 | 	mov	$_fout+6,_fout+4
64 | 	mov	$512.,_fout+2
65 | 	cmp	_fout,$2
66 | 	bhi	1f
67 | 	mov	$1,_fout+2
68 | 1:
69 | 	rts	pc
70 | 
71 | .bss
72 | _fout:	.=.+518.
73 | 
74 | 
75 | 
76 | 
77 | 
78 | 
79 | 
80 | 
81 | 
82 | 
83 | 
84 | 


--------------------------------------------------------------------------------
/usr/source/s/s2/tp4.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s2/tp4.s
 3 | 

V6/usr/source/s2/tp4.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | / tap4 -- dec-tape lod/dmp
19 | 
20 | .data
21 | tc:	</dev/tap>
22 | tcx:	<x\0>
23 | mt:	</dev/mt>
24 | mtx:	<0\0>
25 | tboot:	</usr/mdec/tboot\0>
26 | mboot:	</usr/mdec/mboot\0>
27 | .even
28 | .bss
29 | dir:	. = .+[mdirent*dirsiz]
30 | tapeb:
31 | map:	.=.+4096.
32 | emap:
33 | ch:	.=.+1
34 | flc:	.=.+1
35 | flf:	.=.+1
36 | fli:	.=.+1
37 | flm:	.=.+1
38 | flu:	.=.+1
39 | flv:	.=.+1
40 | flw:	.=.+1
41 | .even
42 | 
43 | command:.=.+2
44 | sum:	.=.+2
45 | size:	.=.+2
46 | nentr:	.=.+2
47 | nused:	.=.+2
48 | nfree:	.=.+2
49 | lused:	.=.+2
50 | catlb:	.=.+20.
51 | narg:	.=.+2
52 | rnarg:	.=.+2
53 | parg:	.=.+2
54 | fio:	.=.+2
55 | mss:	.=.+2
56 | ndirent:.=.+2
57 | ndentd8:.=.+2
58 | edir:	.=.+2
59 | rseeka:	.=.+2
60 | wseeka:	.=.+2
61 | tapsiz:	.=.+2
62 | name:	.=.+32.
63 | name1:	.=.+32.
64 | statb:	.=.+40.
65 | 
66 | smdate = 30.
67 | 
68 | 
69 | 
70 | 
71 | 
72 | 
73 | 
74 | 
75 | 
76 | 
77 | 
78 | 


--------------------------------------------------------------------------------
/usr/sys/proc.h:
--------------------------------------------------------------------------------
 1 | /*
 2 |  * One structure allocated per active
 3 |  * process. It contains all data needed
 4 |  * about the process while the
 5 |  * process may be swapped out.
 6 |  * Other per process data (user.h)
 7 |  * is swapped with the process.
 8 |  */
 9 | struct	proc
10 | {
11 | 	char	p_stat;
12 | 	char	p_flag;
13 | 	char	p_pri;		/* priority, negative is high */
14 | 	char	p_sig;		/* signal number sent to this process */
15 | 	char	p_uid;		/* user id, used to direct tty signals */
16 | 	char	p_time;		/* resident time for scheduling */
17 | 	char	p_cpu;		/* cpu usage for scheduling */
18 | 	char	p_nice;		/* nice for scheduling */
19 | 	int	p_ttyp;		/* controlling tty */
20 | 	int	p_pid;		/* unique process id */
21 | 	int	p_ppid;		/* process id of parent */
22 | 	int	p_addr;		/* address of swappable image */
23 | 	int	p_size;		/* size of swappable image (*64 bytes) */
24 | 	int	p_wchan;	/* event process is awaiting */
25 | 	int	*p_textp;	/* pointer to text structure */
26 | } proc[NPROC];
27 |  
28 | /* stat codes */
29 | #define	SSLEEP	1		/* sleeping on high priority */
30 | #define	SWAIT	2		/* sleeping on low priority */
31 | #define	SRUN	3		/* running */
32 | #define	SIDL	4		/* intermediate state in process creation */
33 | #define	SZOMB	5		/* intermediate state in process termination */
34 | #define	SSTOP	6		/* process being traced */
35 |  
36 | /* flag codes */
37 | #define	SLOAD	01		/* in core */
38 | #define	SSYS	02		/* scheduling process */
39 | #define	SLOCK	04		/* process cannot be swapped */
40 | #define	SSWAP	010		/* process is being swapped out */
41 | #define	STRC	020		/* process is being traced */
42 | #define	SWTED	040		/* another tracing flag */


--------------------------------------------------------------------------------
/usr/source/s/s2/mkdir.s:
--------------------------------------------------------------------------------
  1 | / makdir -- make a directory
  2 | 
  3 | 	sys	getuid
  4 | 	mov	r0,uid
  5 | 	mov	sp,r5
  6 | 	tst	(r5)+
  7 | 
  8 | loop:
  9 | 	tst	(r5)+
 10 | 	dec	(sp)
 11 | 	bgt	1f
 12 | 	sys	exit
 13 | 1:
 14 | 	mov	(r5),r0
 15 | 	mov	$buf1,r1
 16 | 	mov	$buf2,r2
 17 | 	clr	r3
 18 | 1:
 19 | 	movb	(r0)+,r4
 20 | 	beq	2f
 21 | 	movb	r4,(r1)+
 22 | 	movb	r4,(r2)+
 23 | 	cmpb	r4,$'/
 24 | 	bne	1b
 25 | 	mov	r2,r3
 26 | 	br	1b
 27 | 2:
 28 | 	movb	$'/,(r1)+
 29 | 	movb	$'.,(r1)+
 30 | 	clrb	(r1)
 31 | 	mov	$dot,dir
 32 | 	tst	r3
 33 | 	beq	1f
 34 | 	mov	$buf2,dir
 35 | 	clrb	(r3)
 36 | 	cmp	r3,$buf2+1
 37 | 	beq	1f
 38 | 	clrb	-(r3)		/ ???
 39 | 1:
 40 | 	tstb	uid
 41 | 	beq	2f
 42 | 	sys	stat; dir:..; stbuf	/ status of parent dir
 43 | 	bes	error
 44 | 	mov	stbuf+4,r0
 45 | 	cmpb	uid,stbuf+7
 46 | 	bne	1f
 47 | 	ash	$-6,r0
 48 | 1:
 49 | 	ror	r0
 50 | 	ror	r0
 51 | 	bcc	error			/ no write permission in parent
 52 | 2:
 53 | 	mov	(r5),0f
 54 | 	sys	makdir; 0:..; 140777; 0
 55 | 	bes	error			/ prob already exists
 56 | 	mov	(r5),0f
 57 | 	sys	chown; 0:..; uid:..
 58 | 	mov	(r5),0f
 59 | 	sys	link; 0:..; buf1
 60 | 	bes	error
 61 | 	movb	$'.,(r1)+
 62 | 	clrb	(r1)
 63 | 	mov	dir,0f
 64 | 	sys	link; 0:..; buf1
 65 | 	bec	loop
 66 | 
 67 | error:
 68 | 	mov	(r5),r0
 69 | 	mov	r0,0f
 70 | 	clr	0f+2
 71 | 1:
 72 | 	tstb	(r0)+
 73 | 	beq	1f
 74 | 	inc	0f+2
 75 | 	br	1b
 76 | 1:
 77 | 	mov	$1,r0
 78 | 	sys	write; 0:..; ..
 79 | 	mov	$1,r0
 80 | 	sys	write; ques; 3
 81 | 	br	loop
 82 | 
 83 | dot:	<.\0>
 84 | ques:	< ?\n>
 85 | 	.even
 86 | 
 87 | .bss
 88 | buf1:	.=.+100.
 89 | buf2:	.=.+100.
 90 | stbuf:	.=.+40.
 91 | 
 92 | 
 93 | 
 94 | 
 95 | 
 96 | 
 97 | 
 98 | 
 99 | 
100 | 
101 | 
102 | 
103 | 


--------------------------------------------------------------------------------
/usr/source/s/s1/db4.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s1/db4.s
 3 | 

V6/usr/source/s1/db4.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | / db4 -- debugger
19 | 
20 | maxsym = 24000.
21 | core:
22 |    <core\0>
23 | a.out:
24 |    <a.out\0>
25 | .even
26 | zero:	0
27 | .bss
28 | regbuf:
29 | 	.=.+1024.
30 | sigp	= regbuf+310
31 | txtsiz	= regbuf+322
32 | datsiz	= regbuf+324
33 | stksiz	= regbuf+326
34 | rtxtsiz: .=.+2
35 | .data
36 | objmagic: 407
37 | nobjmagic: 410
38 | namsiz:	nambuf
39 | incdot: 2
40 | nlcom: '/
41 | 
42 | 	.bss
43 | 
44 | starmod:.=.+2
45 | symbol:	.=.+10.
46 | getoff:	.=.+2
47 | namstrt: .=.+2
48 | bytemod: .=.+2
49 | savsp: .=.+2
50 | error: .=.+2
51 | ttyfin: .=.+2
52 | dbfin: .=.+2
53 | symfin:	.=.+2
54 | curfin:	.=.+2
55 | dbfout: .=.+2
56 | ch: .=.+2
57 | lastop: .=.+2
58 | addres: .=.+2
59 | taddr: .=.+2
60 | adrflg: .=.+2
61 | fpsr:	.=.+2
62 | och:	.=.+2
63 | dot: .=.+2
64 | count: .=.+2
65 | syscnt: .=.+2
66 | temp: .=.+2
67 | temp1: .=.+2
68 | obuf: .=.+8.
69 | inbuf: .=.+128.
70 | nambuf:	.=.+20
71 | 
72 | 
73 | 
74 | 
75 | 
76 | 
77 | 
78 | 
79 | 
80 | 
81 | 
82 | 
83 | 


--------------------------------------------------------------------------------
/usr/source/s/s2/mesg.c:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s2/mesg.c
 3 | 

V6/usr/source/s2/mesg.c

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | /*
19 |  * mesg -- set current tty to accept or
20 |  *	forbid write permission.
21 |  *
22 |  *	mesg [y] [n]
23 |  *		y allow messages
24 |  *		n forbid messages
25 |  */
26 | 
27 | int	sbuf[40];
28 | 
29 | main(argc, argv)
30 | char *argv[];
31 | {
32 | 	register char *tty;
33 | 
34 | 	tty = "/dev/ttyx";
35 | 	tty[8] = ttyn(1);
36 | 	if(stat(tty, sbuf) < 0) {
37 | 		write(2, "cannot stat\n", 12);
38 | 		exit(1);
39 | 	}
40 | 	if(argc < 2) {
41 | 		if(sbuf[2] & 02)
42 | 			goto no;
43 | 		goto yes;
44 | 	}
45 | 	if(*argv[1] == 'y')
46 | 		goto yes;
47 | 
48 | no:
49 | 	if(chmod(tty, 0600) < 0)
50 | 		goto bad;
51 | 	goto was;
52 | 
53 | yes:
54 | 	if(chmod(tty, 0622) < 0)
55 | 		goto bad;
56 | 
57 | was:
58 | 	if(sbuf[2] & 02)
59 | 		write(2, "was y\n", 6); else
60 | 		write(2, "was n\n", 6);
61 | 	exit(0);
62 | 
63 | bad:
64 | 	write(2, "cannot change mode\n", 19);
65 | 	exit(1);
66 | }
67 | 
68 | 
69 | 
70 | 
71 | 
72 | 
73 | 
74 | 
75 | 
76 | 
77 | 
78 | 


--------------------------------------------------------------------------------
/usr/sys/dmr/dn.c:
--------------------------------------------------------------------------------
 1 | /*
 2 |  * DN-11 ACU interface
 3 |  */
 4 |  
 5 | #include "../param.h"
 6 | #include "../conf.h"
 7 | #include "../user.h"
 8 |  
 9 | struct dn {
10 | 	struct {
11 | 		char	dn_stat;
12 | 		char	dn_reg;
13 | 	} dn11[3];
14 | }
15 |  
16 | #define	DNADDR	0175200
17 |  
18 | #define	PWI	00200
19 | #define	ACR	00100
20 | #define	DLO	0020
21 | #define	DONE	0200
22 | #define	IENABLE	0100
23 | #define	DSS	040
24 | #define	PND	020
25 | #define	MENABLE	04
26 | #define	DPR	02
27 | #define	CRQ	01
28 |  
29 | #define	DNPRI	5
30 |  
31 | dnopen(dev, flag)
32 | {
33 | 	register struct dn *dp;
34 | 	register int rdev;
35 |  
36 | 	rdev = dev.d_minor;
37 | 	dp = &DNADDR->dn11[rdev];
38 | 	if (dp->dn_reg&(PWI|DLO))
39 | 		u.u_error = ENXIO;
40 | 	else {
41 | 		DNADDR->dn11[0].dn_stat =| MENABLE;
42 | 		dp->dn_stat = IENABLE|MENABLE|CRQ;
43 | 	}
44 | }
45 |  
46 | dnclose(dev)
47 | {
48 | 	DNADDR->dn11[dev.d_minor].dn_stat =& MENABLE;
49 | }
50 |  
51 | dnwrite(dev)
52 | {
53 | 	register struct dn *dp;
54 | 	register c;
55 | 	extern lbolt;
56 |  
57 | 	dp = &DNADDR->dn11[dev.d_minor];
58 | 	for(;;) {
59 | 		while ((dp->dn_stat&DONE)==0)
60 | 			sleep(DNADDR, DNPRI);
61 | 		dp->dn_stat =& ~DONE;
62 | 	    contin:
63 | 		if (dp->dn_reg&(PWI|ACR)) {
64 | 			u.u_error = EIO;
65 | 			return;
66 | 		}
67 | 		if (dp->dn_stat&DSS)
68 | 			return;
69 | 		c = 0;
70 | 		if (u.u_count==0 || (dp->dn_stat&PND)==0 || (c=cpass())<0)
71 | 			continue;
72 | 		if (c=='-') {
73 | 			sleep(&lbolt, DNPRI);
74 | 			sleep(&lbolt, DNPRI);
75 | 			goto contin;
76 | 		}
77 | 		dp->dn_reg = c-'0';
78 | 		dp->dn_stat =| DPR;
79 | 	}
80 | }
81 |  
82 | dnint(dev)
83 | {
84 | 	wakeup(DNADDR);
85 | }


--------------------------------------------------------------------------------
/usr/source/s/s1/ln.c:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s1/ln.c
 3 | 

V6/usr/source/s1/ln.c

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | #
19 | /*
20 |  * ln target [ new name ]
21 |  */
22 | 
23 | struct ibuf {
24 | 	int	inum;
25 | 	int	iflags;
26 | 	char	inl;
27 | 	char	iuid;
28 | 	int	isize;
29 | 	int	iaddr[8];
30 | 	char	*ictime[2];
31 | 	char	*imtime[2];
32 | 	int	fill;
33 | };
34 | 
35 | #define	DIR	040000
36 | #define	FMT	060000
37 | 
38 | main(argc, argv)
39 | char **argv;
40 | {
41 | 	static struct ibuf statb;
42 | 	register char *np;
43 | 
44 | 	if (argc<2) {
45 | 		write(1, "Usage: ln target [ newname ]\n", 29);
46 | 		exit(1);
47 | 	}
48 | 	if (argc==2) {
49 | 		np = argv[1];
50 | 		while(*np++);
51 | 		while (*--np!='/' && np>argv[1]);
52 | 		np++;
53 | 		argv[2] = np;
54 | 	}
55 | 	stat(argv[1], &statb);
56 | 	if ((statb.iflags&FMT) == DIR) {
57 | 		write(1, "No directory link\n", 18);
58 | 		exit(1);
59 | 	}
60 | 	if (link(argv[1], argv[2])<0) {
61 | 		write(1, "Can't link\n", 11);
62 | 		exit(1);
63 | 	}
64 | 	exit(0);
65 | }
66 | 
67 | 
68 | 
69 | 
70 | 
71 | 
72 | 
73 | 
74 | 
75 | 
76 | 
77 | 


--------------------------------------------------------------------------------
/usr/source/s/s4/errlst.c:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s4/errlst.c
 3 | 

V6/usr/source/s4/errlst.c

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | char	*sys_errlist[] {
19 | 	"Error 0",
20 | 	"Not super-user",
21 | 	"No such file or directory",
22 | 	"No such process",
23 | 	"Interrupted system call",
24 | 	"I/O error",
25 | 	"No such device or address",
26 | 	"Arg list too long",
27 | 	"Exec format error",
28 | 	"Bad file number",
29 | 	"No children",
30 | 	"No more processes",
31 | 	"Not enough core",
32 | 	"Permission denied",
33 | 	"Error 14",
34 | 	"Block device required",
35 | 	"Mount device busy",
36 | 	"File exists",
37 | 	"Cross-device link",
38 | 	"No such device",
39 | 	"Not a directory",
40 | 	"Is a directory",
41 | 	"Invalid argument",
42 | 	"File table overflow",
43 | 	"Too many open files",
44 | 	"Not a typewriter",
45 | 	"Text file busy",
46 | 	"File too large",
47 | 	"No space left on device",
48 | 	"Illegal seek",
49 | 	"Read-only file system",
50 | 	"Too many links",
51 | 	"Broken Pipe",
52 | };
53 | int	sys_nerr { sizeof sys_errlist/sizeof sys_errlist[0] };
54 | 
55 | 
56 | 
57 | 
58 | 
59 | 
60 | 
61 | 
62 | 
63 | 
64 | 
65 | 


--------------------------------------------------------------------------------
/usr/source/s/s1/cat.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s1/cat.s
 3 | 

V6/usr/source/s1/cat.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | / cat -- concatinate files
19 | 
20 | 	mov	(sp)+,r5
21 | 	tst	(sp)+
22 | 	mov	$obuf,r2
23 | 	cmp	r5,$1
24 | 	beq	3f
25 | 
26 | loop:
27 | 	dec	r5
28 | 	ble	done
29 | 	mov	(sp)+,r0
30 | 	cmpb	(r0),$'-
31 | 	bne	2f
32 | 	clr	fin
33 | 	br	3f
34 | 2:
35 | 	mov	r0,0f
36 | 	sys	open; 0:..; 0
37 | 	bes	loop
38 | 	mov	r0,fin
39 | 3:
40 | 	mov	fin,r0
41 | 	sys	read; ibuf; 512.
42 | 	bes	3f
43 | 	mov	r0,r4
44 | 	beq	3f
45 | 	mov	$ibuf,r3
46 | 4:
47 | 	movb	(r3)+,r0
48 | 	jsr	pc,putc
49 | 	dec	r4
50 | 	bne	4b
51 | 	br	3b
52 | 3:
53 | 	mov	fin,r0
54 | 	beq	loop
55 | 	sys	close
56 | 	br	loop
57 | 
58 | done:
59 | 	sub	$obuf,r2
60 | 	beq	1f
61 | 	mov	r2,0f
62 | 	mov	$1,r0
63 | 	sys	write; obuf; 0:..
64 | 1:
65 | 	sys	exit
66 | 
67 | putc:
68 | 	movb	r0,(r2)+
69 | 	cmp	r2,$obuf+512.
70 | 	blo	1f
71 | 	mov	$1,r0
72 | 	sys	write; obuf; 512.
73 | 	mov	$obuf,r2
74 | 1:
75 | 	rts	pc
76 | 
77 | 	.bss
78 | ibuf:	.=.+512.
79 | obuf:	.=.+512.
80 | fin:	.=.+2
81 | 	.text
82 | 
83 | 
84 | 
85 | 
86 | 
87 | 
88 | 
89 | 
90 | 
91 | 
92 | 
93 | 
94 | 


--------------------------------------------------------------------------------
/usr/source/s/s2/tee.c:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s2/tee.c
 3 | 

V6/usr/source/s2/tee.c

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | int open[9] { 1 };
19 | int n 1;
20 | int t 0;
21 | 
22 | char in[512];
23 | 
24 | char out[512];
25 | 
26 | main(argc,argv)
27 | char **argv;
28 | {
29 | 	int register r,w,p;
30 | 	struct { int x1[2], type, x2[15]; } buf;
31 | 	fstat(1,&buf);
32 | 	t = (buf.type&060000)==020000;
33 | 	while(argc-->1) {
34 | 		open[n++] = creat(argv[1],0666);
35 | 		if(stat(argv[1],&buf)>=0)
36 | 			if((buf.type&060000)==020000)
37 | 				t++;
38 | 		argv++;
39 | 	}
40 | 	r = w = 0;
41 | 	for(;;) {
42 | 		for(p=0;p<512;) {
43 | 			if(r>=w) {
44 | 				if(t>0&&p>0) break;
45 | 				w = read(0,in,512);
46 | 				r = 0;
47 | 				if(w<=0) {
48 | 					stash(p);
49 | 					return;
50 | 				}
51 | 			}
52 | 			out[p++] = in[r++];
53 | 		}
54 | 		stash(p);
55 | 	}
56 | }
57 | 
58 | stash(p)
59 | {
60 | 	int k;
61 | 	int i;
62 | 	int d;
63 | 	d = t ? 10 : p;
64 | 	for(i=0; i<p; i=+d)
65 | 		for(k=0;k<n;k++)
66 | 			write(open[k], out+i, d<p-i?d:p-i);
67 | }
68 | 
69 | 
70 | 
71 | 
72 | 
73 | 
74 | 
75 | 
76 | 
77 | 
78 | 
79 | 


--------------------------------------------------------------------------------
/usr/source/s/s3/sqrt.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s3/sqrt.s
 3 | 

V6/usr/source/s3/sqrt.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | ldfps = 170100^tst
19 | stfps = 170200^tst
20 | /
21 | /	sqrt replaces the f.p. number in fr0 by its
22 | /	square root.  newton's method
23 | /
24 | .globl	sqrt, _sqrt
25 | /
26 | /
27 | _sqrt:
28 | 	mov	r5,-(sp)
29 | 	mov	sp,r5
30 | 	movf	4(r5),fr0
31 | 	jsr	pc,sqrt
32 | 	mov	(sp)+,r5
33 | 	rts	pc
34 | 
35 | sqrt:
36 | 	tstf	fr0
37 | 	cfcc
38 | 	bne	1f
39 | 	clc
40 | 	rts	pc		/sqrt(0)
41 | 1:
42 | 	bgt	1f
43 | 	clrf	fr0
44 | 	sec
45 | 	rts	pc		/ sqrt(-a)
46 | 1:
47 | 	mov	r0,-(sp)
48 | 	stfps	-(sp)
49 | 	mov	(sp),r0
50 | 	bic	$!200,r0		/ retain mode
51 | 	ldfps	r0
52 | 	movf	fr1,-(sp)
53 | 	movf	fr2,-(sp)
54 | /
55 | 	movf	fr0,fr1
56 | 	movf	fr0,-(sp)
57 | 	asr	(sp)
58 | 	add	$20100,(sp)
59 | 	movf	(sp)+,fr0	/initial guess
60 | 	mov	$4,r0
61 | 1:
62 | 	movf	fr1,fr2
63 | 	divf	fr0,fr2
64 | 	addf	fr2,fr0
65 | 	mulf	$half,fr0	/ x = (x+a/x)/2
66 | 	sob	r0,1b
67 | 2:
68 | 	movf	(sp)+,fr2
69 | 	movf	(sp)+,fr1
70 | 	ldfps	(sp)+
71 | 	mov	(sp)+,r0
72 | 	clc
73 | 	rts	pc
74 | /
75 | half	= 40000
76 | 
77 | 
78 | 
79 | 
80 | 
81 | 
82 | 
83 | 
84 | 
85 | 
86 | 
87 | 


--------------------------------------------------------------------------------
/usr/source/s/s1/diff2.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s1/diff2.s
 3 | 

V6/usr/source/s1/diff2.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | /	hash routine for diff
19 | /	effectively spreads the string out into 7-bit
20 | /	bytes, then sums the result 1's-complement
21 | /	by 16-bit bytes and adds 1 to avoid zero answer
22 | 
23 | /	r4 hash accumulator
24 | /	r3 current offset
25 | /	r2 first time flag
26 | .globl	_readhash
27 | .globl getc
28 | 
29 | .data
30 | _readhash:
31 | 	mov	2(sp),0f
32 | 	mov	r5,-(sp)
33 | 	mov	r4,-(sp)
34 | 	mov	r3,-(sp)
35 | 	mov	r2,-(sp)
36 | 	mov	$1,r4
37 | 	mov	r4,r2
38 | 	clr	r3
39 | 1:
40 | 	jsr	r5,getc; 0: 0
41 | 	bes	2f
42 | 	clr	r2
43 | 	cmp	r0,$'\n
44 | 	beq	1f
45 | 	ashc	$-16.,r0
46 | 	ashc	r3,r0
47 | 	add	r0,r4
48 | 	adc	r4
49 | 	add	r1,r4
50 | 	adc	r4
51 | 	add	$7,r3
52 | 	cmp	r3,$16.
53 | 	blt	1b
54 | 	sub	$16.,r3
55 | 	br	1b
56 | 2:
57 | 	tst	r2
58 | 	bne	2f
59 | 	mov	$2,r0
60 | 	sys	write; 3f; 4f-3f
61 | 2:
62 | 	clr	r4
63 | 1:
64 | 	mov	r4,r0
65 | 	mov	(sp)+,r2
66 | 	mov	(sp)+,r3
67 | 	mov	(sp)+,r4
68 | 	mov	(sp)+,r5
69 | 	rts	pc
70 | 3:
71 | 	<incomplete line omitted\n>
72 | 4:
73 | .even
74 | 
75 | 
76 | 
77 | 
78 | 
79 | 
80 | 
81 | 
82 | 
83 | 
84 | 
85 | 


--------------------------------------------------------------------------------
/usr/sys/conf/low.s:
--------------------------------------------------------------------------------
 1 | / low core
 2 | 
 3 |  br4 = 200 
 4 |  br5 = 240
 5 |  br6 = 300 
 6 |  br7 = 340 
 7 |  
 8 | . = 0^.
 9 |     br 1f		
10 |     4			
11 | 
12 |  / trap vectors
13 |     trap; br7+0.	/ bus error       
14 |     trap; br7+1.	/ illegal instruction 
15 |     trap; br7+2.	/ bpt-trace trap 
16 |     trap; br7+3.	/ iot trap 
17 |     trap; br7+4.	/ power fail 
18 |     trap; br7+5.	/ emulator trap 
19 |     trap; br7+6.	/ system entry 
20 | 
21 |  . = 40^.
22 |  .globl     start, dump
23 |  1: jmp     start
24 |     jmp     dump
25 | 
26 |  . = 60^.		
27 |     klin; br4 
28 |     klou; br4
29 | 
30 |  . = 70^.
31 |     pcin; br4
32 |     pcou; br4
33 | 
34 |  . = 100^.			
35 |     kwlp; br6 
36 |     kwlp; br6 
37 | 
38 |  . = 114^.
39 |     trap; br7+7./ 11/70 parity
40 | 
41 |  . = 200^.
42 |     lpou; br4
43 | 
44 |  . = 220^.			
45 |     rkio; br5
46 | 
47 |  . = 240^.   
48 |     trap; br7+7./ programmed interrupt
49 |     trap; br7+8./ floating point
50 |     trap; br7+9./ segmentation violation 
51 |  /////////////////////////////////////////////////////////
52 |  /interface code to C
53 |  /////////////////////////////////////////////////////////
54 | 																									
55 |  .globl     call, trap																				
56 | 																								
57 |  .globl     _klrint                                    
58 |  klin:jsr     r0,call; _klrint 		
59 | 
60 |  .globl     _klxint
61 |  klou:jsr     r0,call; _klxint
62 | 
63 |  .globl     _pcrint
64 |  pcin:jsr     r0,call; _pcrint
65 | 
66 |  .globl     _pcpint
67 |  pcou:jsr     r0,call; _pcpint
68 | 
69 |  .globl     _clock
70 |  kwlp:jsr     r0,call; _clock
71 | 
72 | 
73 |  .globl     _lpint
74 |  lpou:jsr     r0,call; _lpint
75 | 
76 |  .globl     _rkintr
77 |  rkio:jsr     r0,call; _rkintr
78 | 


--------------------------------------------------------------------------------
/usr/personal/user/include/comm.h:
--------------------------------------------------------------------------------
 1 | #ifndef _COMM_H_
 2 | #define _COMM_H_
 3 | #include "param.h"
 4 | /*
 5 |  * Semphore sys call
 6 |  */
 7 | int CreateSemphore(int initNum);
 8 | int CloseSemphore(int sd);
 9 | int AcquireSemphore(int sd);
10 | int ReleaseSemphore(int sd);
11 | 
12 | /*
13 |  * Mutex sys call
14 |  */
15 | int CreateMutex();
16 | int CloseMutex(int md);
17 | int AcquireMutex(int md);
18 | int ReleaseMutex(int md);
19 | 
20 | /*
21 |  * Event sys call
22 |  */
23 | #define 		WT_IMME					0
24 | #define 		WT_INFINITE			-1
25 | 
26 | int CreateEvent(BOOL initStatus);
27 | int CloseEvent(int ed);
28 | int WaitEvent(int ed, int time);
29 | int SetEvent(int ed);
30 | 
31 | /*
32 |  * Message sys call
33 |  */
34 | int SendMessage(int pid, char *msg, int len, int time);
35 | int ReceiveMessage(char *msg, int len, int time);
36 | 
37 | /*
38 |  * Mail sys call
39 |  */
40 | int CreatePrivMbx(char *name);
41 | int CloseMbx(int md);
42 | int SendMail(char *name, char *mail, int len, int time);
43 | int ReceiveMail(int mbxd, char *mail, int len, int time);
44 | 
45 | int CreateSharedMbx();
46 | int SendSharedMail(int mbxd, char *mail, int len, int time);
47 | 
48 | int CreatePublicMbx (char *name);
49 | int ClosePublicMbx(char *name);
50 | int ReceivePublicMail(char *name, char *mail, int len, int time);
51 | 
52 | /*
53 |  * Shared memory sys call
54 |  */
55 | #define PERMISSION_READ				1
56 | #define PERMISSION_WRITE				2
57 | #define PERMISSION_ALL			(PERMISSION_WRITE| PERMISSION_READ)
58 | struct MapShm
59 | {
60 | 	int *addr;
61 | 	int size;
62 | };
63 | 
64 | int CreateSharedMemory(char *name, int blocks, int ownpermin, int otherpermin);
65 | int FreeSharedMemory(int shd);
66 | int MapSharedMemory(char *name, MapShm *ms);
67 | int UnmapSharedMemory(int shd);
68 |  
69 | #endif


--------------------------------------------------------------------------------
/usr/source/s/solloc/getwd.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/salloc/getwd.s
 3 | 

V6/usr/source/salloc/getwd.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | .globl	getword
19 | .globl	putword
20 | .globl lookword
21 | .globl alterword
22 | .globl alterchar
23 | .globl	putchar
24 | .globl	lookchar
25 | .globl	w, r, a, l
26 | /
27 | /	routine to put a word onto the string
28 | /	mov	...,r1
29 | /	mov	...,r0
30 | /	jsr	pc,putword
31 | putword:
32 | 	jsr	pc,putchar
33 | 	swab	r0
34 | 	jsr	pc,putchar
35 | 	swab	r0
36 | 	rts	pc
37 | /
38 | /
39 | /	routine to look at a word from the string
40 | /	mov	...,r1
41 | /	jsr	pc,lookword
42 | /	mov	r0,...
43 | lookword:
44 | 	jsr	pc,lookchar
45 | 	bes	1f
46 | 	movb	r0,nchar
47 | 	inc	r(r1)
48 | 	jsr	pc,lookchar
49 | 	bes	1f
50 | 	movb	r0,nchar+1
51 | 	dec	r(r1)
52 | 	mov	nchar,r0
53 | 1:	rts	pc
54 | /
55 | /
56 | /	routine to get a word from the strng
57 | /
58 | getword:
59 | 	jsr	pc,lookword
60 | 	bes	1f
61 | 	add	$2,r(r1)
62 | 1:	rts	pc
63 | /
64 | /
65 | /	routine to alter a word in the string
66 | /
67 | alterword:
68 | 	jsr	pc,alterchar
69 | 	swab	r0
70 | 	jsr	pc,alterchar
71 | 	swab	r0 
72 | 	rts	pc
73 | nchar:	.=.+2
74 | 
75 | 
76 | 
77 | 
78 | 
79 | 
80 | 
81 | 
82 | 
83 | 
84 | 
85 | 


--------------------------------------------------------------------------------
/usr/source/s/s1/clri.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s1/clri.s
 3 | 

V6/usr/source/s1/clri.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | / clri -- clear inode
19 | 
20 | 	cmp	(sp)+,$2
21 | 	blt	error
22 | 	beq	1f
23 | 	mov	4(sp),fs1
24 | 	mov	4(sp),fs2
25 | 1:
26 | 	tst	(sp)+
27 | 	mov	(sp)+,r0
28 | 	clr	r5
29 | 1:
30 | 	movb	(r0)+,r1
31 | 	beq	1f
32 | 	mpy	$10.,r5
33 | 	sub	$'0,r1
34 | 	cmp	r1,$10.
35 | 	bhis	error
36 | 	add	r1,r5
37 | 	br	1b
38 | 1:
39 | 	add	$31.,r5
40 | 	mov	r5,r0
41 | 	als	$-4,r0
42 | 	mov	r0,0f
43 | 	sys	open; fs1: filsys; 0
44 | 	bes	error
45 | 	mov	r0,-(sp)
46 | 	sys	seek; 0:..; 3
47 | 	mov	(sp),r0
48 | 	sys	read; buf; 512.
49 | 	mov	(sp)+,r0
50 | 	sys	close
51 | 	mov	r5,r0
52 | 	als	$5,r0
53 | 	bic	$!777,r0
54 | 	add	$buf,r0
55 | 	mov	$16.,r5
56 | 1:
57 | 	clr	(r0)+
58 | 	sob	r5,1b
59 | 	sys	open; fs2: filsys; 1
60 | 	bes	error
61 | 	mov	r0,-(sp)
62 | 	mov	0b,0f
63 | 	sys	seek; 0:..; 3
64 | 	mov	(sp)+,r0
65 | 	sys	write; buf; 512.
66 | 	bes	error
67 | 	sys	exit
68 | 
69 | error:
70 | 	mov	$1,r0
71 | 	sys	write; 1f; 2f-1f
72 | 	sys	exit
73 | 1:
74 | 	<error\n>
75 | 2:
76 | 
77 | filsys:	</dev/junk\0>
78 | .even
79 | 	.bss
80 | buf:	.=.+512.
81 | 
82 | 
83 | 
84 | 
85 | 
86 | 
87 | 
88 | 
89 | 
90 | 
91 | 
92 | 


--------------------------------------------------------------------------------
/usr/source/s/s5/mcrt0.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s5/mcrt0.s
 3 | 

V6/usr/source/s5/mcrt0.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | / C runtime startoff including monitoring
19 | 
20 | cbufs	= 150.
21 | 
22 | .globl	_monitor
23 | .globl	_sbrk
24 | .globl	_main
25 | .globl	_exit
26 | .globl	_etext
27 | .comm	countbase,2
28 | 
29 | .comm	savr5,2
30 | 
31 | start:
32 | 	setd
33 | 	mov	sp,r0
34 | 	mov	(r0),-(sp)
35 | 	tst	(r0)+
36 | 	mov	r0,2(sp)
37 | 
38 | 	mov	$_etext,r1
39 | 	sub	$eprol,r1
40 | 	add	$7,r1
41 | 	ash	$-3,r1
42 | 	bic	$!17777,r1
43 | 	mov	$cbufs,-(sp)
44 | 	add	$3*[cbufs+1],r1
45 | 	mov	r1,-(sp)
46 | 	asl	r1
47 | 	mov	r1,-(sp)
48 | 	jsr	pc,_sbrk
49 | 	tst	(sp)+
50 | 	cmp	r0,$-1
51 | 	beq	9f
52 | 	mov	r0,-(sp)
53 | 	add	$6,r0
54 | 	mov	r0,countbase
55 | 	mov	$_etext,-(sp)
56 | 	mov	$eprol,-(sp)
57 | 	jsr	pc,_monitor
58 | 	add	$10.,sp
59 | 	jsr	pc,_main
60 | 	cmp	(sp)+,(sp)+
61 | 	jsr	pc,_exit
62 | 
63 | 9:
64 | 	mov	$2,r0
65 | 	sys	write; 8f; 9f-8f
66 | 
67 | .data; 8: <No space for monitor buffer\n>; 9:.even; .text
68 | 
69 | _exit:
70 | 	mov	r5,-(sp)
71 | 	mov	sp,r5
72 | 	clr	-(sp)
73 | 	jsr	pc,_monitor
74 | 	tst	(sp)+
75 | 	mov	4(r5),r0
76 | 	sys	exit
77 | eprol:
78 | 
79 | 
80 | 
81 | 
82 | 
83 | 
84 | 
85 | 
86 | 
87 | 
88 | 
89 | 


--------------------------------------------------------------------------------
/usr/sys/inode.h:
--------------------------------------------------------------------------------
 1 | /*
 2 |  * The I node is the focus of all
 3 |  * file activity in unix. There is a unique
 4 |  * inode allocated for each active file,
 5 |  * each current directory, each mounted-on
 6 |  * file, text file, and the root. An inode is 'named'
 7 |  * by its dev/inumber pair. (iget/iget.c)
 8 |  * Data, from mode on, is read in
 9 |  * from permanent inode on volume.
10 |  */
11 | struct	inode
12 | {
13 | 	char	i_flag;
14 | 	char	i_count;	/* reference count */
15 | 	int	i_dev;		/* device where inode resides */
16 | 	int	i_number;	/* i number, 1-to-1 with device address */
17 | 	int	i_mode;
18 | 	char	i_nlink;	/* directory entries */
19 | 	char	i_uid;		/* owner */
20 | 	char	i_gid;		/* group of owner */
21 | 	char	i_size0;	/* most significant of size */
22 | 	char	*i_size1;	/* least sig */
23 | 	int	i_addr[8];	/* device addresses constituting file */
24 | 	int	i_lastr;	/* last logical block read (for read-ahead) */
25 | } inode[NINODE];
26 |  
27 | /* flags */
28 | #define	ILOCK	01		/* inode is locked */
29 | #define	IUPD	02		/* inode has been modified */
30 | #define	IACC	04		/* inode access time to be updated */
31 | #define	IMOUNT	010		/* inode is mounted on */
32 | #define	IWANT	020		/* some process waiting on lock */
33 | #define	ITEXT	040		/* inode is pure text prototype */
34 |  
35 | /* modes */
36 | #define	IALLOC	0100000		/* file is used */
37 | #define	IFMT	060000		/* type of file */
38 | #define	IFDIR	040000		/* directory */
39 | #define	IFCHR	020000		/* character special */
40 | #define	IFBLK	060000		/* block special, 0 is regular */
41 | #define	ILARG	010000		/* large addressing algorithm */
42 | #define	ISUID	04000		/* set user id on execution */
43 | #define	ISGID	02000		/* set group id on execution */
44 | #define	ISVTX	01000		/* save swapped text even after use */
45 | #define	IREAD	0400		/* read, write, execute permissions */
46 | #define	IWRITE	0200
47 | #define	IEXEC	0100


--------------------------------------------------------------------------------
/usr/source/s/s1/df.c:
--------------------------------------------------------------------------------
  1 | char	*dargv[]
  2 | {
  3 | 	0,
  4 | 	"/dev/rk2",
  5 | 	"/dev/rp0",
  6 | 	0
  7 | };
  8 | struct
  9 | {
 10 | 	char	*s_isize;
 11 | 	char	*s_fsize;
 12 | 	int	s_nfree;
 13 | 	int	s_free[100];
 14 | 	int	s_ninode;
 15 | 	int	s_inode[100];
 16 | 	char	s_flock;
 17 | 	char	s_ilock;
 18 | 	char	s_fmod;
 19 | 	int	time[2];
 20 | 	int	pad[50];
 21 | } sblock;
 22 | 
 23 | int	fi;
 24 | 
 25 | main(argc, argv)
 26 | char **argv;
 27 | {
 28 | 	int i;
 29 | 
 30 | 	if(argc <= 1) {
 31 | 		for(argc = 1; dargv[argc]; argc++);
 32 | 		argv = dargv;
 33 | 	}
 34 | 
 35 | 	for(i=1; i<argc; i++) {
 36 | 		if(argc > 1)
 37 | 			printf("%s ", argv[i]);
 38 | 		dfree(argv[i]);
 39 | 	}
 40 | }
 41 | 
 42 | dfree(file)
 43 | char *file;
 44 | {
 45 | 	int i;
 46 | 
 47 | 	fi = open(file, 0);
 48 | 	if(fi < 0) {
 49 | 		printf("cannot open %s\n", file);
 50 | 		return;
 51 | 	}
 52 | 	sync();
 53 | 	bread(1, &sblock);
 54 | 	i = 0;
 55 | 	while(alloc())
 56 | 		i++;
 57 | 	printf("%l\n", i);
 58 | 	close(fi);
 59 | }
 60 | 
 61 | alloc()
 62 | {
 63 | 	int b, i, buf[256];
 64 | 
 65 | 	i = --sblock.s_nfree;
 66 | 	if(i<0 || i>=100) {
 67 | 		printf("bad free count\n");
 68 | 		return(0);
 69 | 	}
 70 | 	b = sblock.s_free[i];
 71 | 	if(b == 0)
 72 | 		return(0);
 73 | 	if(b<sblock.s_isize+2 || b>=sblock.s_fsize) {
 74 | 		printf("bad free block (%l)\n", b);
 75 | 		return(0);
 76 | 	}
 77 | 	if(sblock.s_nfree <= 0) {
 78 | 		bread(b, buf);
 79 | 		sblock.s_nfree = buf[0];
 80 | 		for(i=0; i<100; i++)
 81 | 			sblock.s_free[i] = buf[i+1];
 82 | 	}
 83 | 	return(b);
 84 | }
 85 | 
 86 | bread(bno, buf)
 87 | {
 88 | 	int n;
 89 | 	extern errno;
 90 | 
 91 | 	seek(fi, bno, 3);
 92 | 	if((n=read(fi, buf, 512)) != 512) {
 93 | 		printf("read error %d\n", bno);
 94 | 		printf("count = %d; errno = %d\n", n, errno);
 95 | 		exit();
 96 | 	}
 97 | }
 98 | 
 99 | 
100 | 
101 | 
102 | 
103 | 
104 | 
105 | 
106 | 
107 | 
108 | 
109 | 


--------------------------------------------------------------------------------
/usr/sys/dmr/dhdm.c:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *	DM-BB driver
 3 |  */
 4 | #include "../param.h"
 5 | #include "../tty.h"
 6 | #include "../conf.h"
 7 |  
 8 | #define	DMADDR	0170500
 9 |  
10 | struct	tty dh11[];
11 | int	ndh11;		/* Set by dh.c to number of lines */
12 |  
13 | #define	DONE	0200
14 | #define	SCENABL	040
15 | #define	CLSCAN	01000
16 | #define	TURNON	07	/* RQ send, CD lead, line enable */
17 | #define	TURNOFF	1	/* line enable only */
18 | #define	CARRIER	0100
19 |  
20 | struct dmregs {
21 | 	int	dmcsr;
22 | 	int	dmlstat;
23 | };
24 |  
25 | /*
26 |  * Turn on the line associated with the (DH) device dev.
27 |  */
28 | dmopen(dev)
29 | {
30 | 	register struct tty *tp;
31 |  
32 | 	tp = &dh11[dev.d_minor];
33 | 	DMADDR->dmcsr = dev.d_minor;
34 | 	DMADDR->dmlstat = TURNON;
35 | 	if (DMADDR->dmlstat&CARRIER)
36 | 		tp->t_state =| CARR_ON;
37 | 	DMADDR->dmcsr = IENABLE|SCENABL;
38 | 	spl5();
39 | 	while ((tp->t_state&CARR_ON)==0)
40 | 		sleep(&tp->t_rawq, TTIPRI);
41 | 	spl0();
42 | }
43 |  
44 | /*
45 |  * If a DH line has the HUPCL mode,
46 |  * turn off carrier when it is closed.
47 |  */
48 | dmclose(dev)
49 | {
50 | 	register struct tty *tp;
51 |  
52 | 	tp = &dh11[dev.d_minor];
53 | 	if (tp->t_flags&HUPCL) {
54 | 		DMADDR->dmcsr = dev.d_minor;
55 | 		DMADDR->dmlstat = TURNOFF;
56 | 		DMADDR->dmcsr = IENABLE|SCENABL;
57 | 	}
58 | }
59 |  
60 | /*
61 |  * DM11 interrupt.
62 |  * Mainly, deal with carrier transitions.
63 |  */
64 | dmint()
65 | {
66 | 	register struct tty *tp;
67 |  
68 | 	if (DMADDR->dmcsr&DONE) {
69 | 		tp = &dh11[DMADDR->dmcsr&017];
70 | 		if (tp < &dh11[ndh11]) {
71 | 			wakeup(tp);
72 | 			if ((DMADDR->dmlstat&CARRIER)==0) {
73 | 				if ((tp->t_state&WOPEN)==0) {
74 | 					signal(tp, SIGHUP);
75 | 					DMADDR->dmlstat = 0;
76 | 					flushtty(tp);
77 | 				}
78 | 				tp->t_state =& ~CARR_ON;
79 | 			} else
80 | 				tp->t_state =| CARR_ON;
81 | 		}
82 | 		DMADDR->dmcsr = IENABLE|SCENABL;
83 | 	}
84 | }


--------------------------------------------------------------------------------
/usr/source/s/s1/goto.c:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s1/goto.c
 3 | 

V6/usr/source/s1/goto.c

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | int	offset	0;
19 | 
20 | main(argc, argv)
21 | char *argv[];
22 | {
23 | 	extern fin;
24 | 	char line[64];
25 | 
26 | 	if (argc<2 || ttyn(0)!='x') {
27 | 		write(1, "goto error\n", 11);
28 | 		seek(0, 0, 2);
29 | 		return;
30 | 	}
31 | 	seek(0, 0, 0);
32 | 	fin = dup(0);
33 | 
34 | loop:
35 | 	if (getlin(line)) {
36 | 		write(1, "label not found\n", 16);
37 | 		return;
38 | 		}
39 | 	if (compar(line, argv[1])) goto loop;
40 | 	seek(0, offset, 0);
41 | }
42 | 
43 | getlin(s)
44 | char s[];
45 | {
46 | 	int ch, i;
47 | 
48 | 	i = 0;
49 | l:
50 | 	if ((ch=getc())=='\0') return(1);
51 | 	if (ch!=':') {
52 | 		while(ch!='\n' && ch!='\0')
53 | 			ch = getc();
54 | 		goto l;
55 | 		}
56 | 	while ((ch=getc())==' ');
57 | 	while (ch!=' ' && ch!='\n' && ch!='\0') {
58 | 		s[i++] = ch;
59 | 		ch = getc();
60 | 		}
61 | 	while(ch != '\n')
62 | 		ch = getc();
63 | 	s[i] = '\0';
64 | 	return(0);
65 | }
66 | 
67 | compar(s1, s2)
68 | char s1[], s2[];
69 | {
70 | 	int c, i;
71 | 
72 | 	i = 0;
73 | l:
74 | 	if(s1[i] != s2[i]) return(1);
75 | 	if (s1[i++] == '\0') return(0);
76 | 	goto l;
77 | }
78 | 
79 | getc()
80 | {
81 | 
82 | 	offset++;
83 | 	return(getchar());
84 | }
85 | 
86 | 
87 | 
88 | 
89 | 
90 | 
91 | 
92 | 
93 | 
94 | 
95 | 
96 | 


--------------------------------------------------------------------------------
/usr/sys/dmr/rf.c:
--------------------------------------------------------------------------------
 1 | /*
 2 |  * RF disk driver
 3 |  */
 4 |  
 5 | #include "../param.h"
 6 | #include "../buf.h"
 7 | #include "../conf.h"
 8 | #include "../user.h"
 9 |  
10 | struct {
11 | 	int	rfcs;
12 | 	int	rfwc;
13 | 	int	rfba;
14 | 	int	rfda;
15 | 	int	rfdae;
16 | };
17 |  
18 | struct	devtab	rftab;
19 | struct	buf	rrfbuf;
20 |  
21 | #define	NRFBLK	1024
22 | #define	RFADDR	0177460
23 |  
24 | #define	GO	01
25 | #define	RCOM	02
26 | #define	WCOM	04
27 | #define	CTLCLR	0400
28 | #define	IENABLE	0100
29 |  
30 | rfstrategy(abp)
31 | struct buf *abp;
32 | {
33 | 	register struct buf *bp;
34 |  
35 | 	bp = abp;
36 | 	if(bp->b_flags&B_PHYS)
37 | 		mapalloc(bp);
38 | 	if (bp->b_blkno >= NRFBLK*(bp->b_dev.d_minor+1)) {
39 | 		bp->b_flags =| B_ERROR;
40 | 		iodone(bp);
41 | 		return;
42 | 	}
43 | 	bp->av_forw = 0;
44 | 	spl5();
45 | 	if (rftab.d_actf==0)
46 | 		rftab.d_actf = bp;
47 | 	else
48 | 		rftab.d_actl->av_forw = bp;
49 | 	rftab.d_actl = bp;
50 | 	if (rftab.d_active==0)
51 | 		rfstart();
52 | 	spl0();
53 | }
54 |  
55 | rfstart()
56 | {
57 | 	register struct buf *bp;
58 |  
59 | 	if ((bp = rftab.d_actf) == 0)
60 | 		return;
61 | 	rftab.d_active++;
62 | 	RFADDR->rfdae = bp->b_blkno.hibyte;
63 | 	devstart(bp, &RFADDR->rfda, bp->b_blkno<<8, 0);
64 | }
65 |  
66 | rfintr()
67 | {
68 | 	register struct buf *bp;
69 |  
70 | 	if (rftab.d_active == 0)
71 | 		return;
72 | 	bp = rftab.d_actf;
73 | 	rftab.d_active = 0;
74 | 	if (RFADDR->rfcs < 0) {		/* error bit */
75 | 		deverror(bp, RFADDR->rfcs, RFADDR->rfdae);
76 | 		RFADDR->rfcs = CTLCLR;
77 | 		if (++rftab.d_errcnt <= 10) {
78 | 			rfstart();
79 | 			return;
80 | 		}
81 | 		bp->b_flags =| B_ERROR;
82 | 	}
83 | 	rftab.d_errcnt = 0;
84 | 	rftab.d_actf = bp->av_forw;
85 | 	iodone(bp);
86 | 	rfstart();
87 | }
88 |  
89 | rfread(dev)
90 | {
91 |  
92 | 	physio(rfstrategy, &rrfbuf, dev, B_READ);
93 | }
94 |  
95 | rfwrite(dev)
96 | {
97 |  
98 | 	physio(rfstrategy, &rrfbuf, dev, B_WRITE);
99 | }


--------------------------------------------------------------------------------
/usr/sys/systm.h:
--------------------------------------------------------------------------------
 1 | /*
 2 |  * Random set of variables
 3 |  * used by more than one
 4 |  * routine.
 5 |  */
 6 | char	canonb[CANBSIZ];	/* buffer for erase and kill (#@) */
 7 | int	coremap[CMAPSIZ];	/* space for core allocation */
 8 | int	swapmap[SMAPSIZ];	/* space for swap allocation */
 9 | int	*rootdir;		/* pointer to inode of root directory */
10 | int	cputype;		/* type of cpu =40, 45, or 70 */
11 | int	execnt;			/* number of processes in exec */
12 | int	lbolt;			/* time of day in 60th not in time */
13 | int	time[2];		/* time in sec from 1970 */
14 | int	tout[2];		/* time of day of next sleep */
15 | /*
16 |  * The callout structure is for
17 |  * a routine arranging
18 |  * to be called by the clock interrupt
19 |  * (clock.c) with a specified argument,
20 |  * in a specified amount of time.
21 |  * Used, for example, to time tab
22 |  * delays on teletypes.
23 |  */
24 | struct	callo
25 | {
26 | 	int	c_time;		/* incremental time */
27 | 	int	c_arg;		/* argument to routine */
28 | 	int	(*c_func)();	/* routine */
29 | } callout[NCALL];
30 | /*
31 |  * Mount structure.
32 |  * One allocated on every mount.
33 |  * Used to find the super block.
34 |  */
35 | struct	mount
36 | {
37 | 	int	m_dev;		/* device mounted */
38 | 	int	*m_bufp;	/* pointer to superblock */
39 | 	int	*m_inodp;	/* pointer to mounted on inode */
40 | } mount[NMOUNT];
41 | int	mpid;			/* generic for unique process id's */
42 | char	runin;			/* scheduling flag */
43 | char	runout;			/* scheduling flag */
44 | char	runrun;			/* scheduling flag */
45 | char	curpri;			/* more scheduling */
46 | int	maxmem;			/* actual max memory per process */
47 | int	*lks;			/* pointer to clock device */
48 | int	rootdev;		/* dev of root see conf.c */
49 | int	swapdev;		/* dev of swap see conf.c */
50 | int	swplo;			/* block number of swap space */
51 | int	nswap;			/* size of swap space */
52 | int	updlock;		/* lock for sync */
53 | int	rablock;		/* block to be read ahead */
54 | char	regloc[];		/* locs. of saved user registers (trap.c) */


--------------------------------------------------------------------------------
/usr/source/s/s2/umount.c:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s2/umount.c
 3 | 

V6/usr/source/s2/umount.c

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | #define	NMOUNT	16
19 | #define	NAMSIZ	32
20 | 
21 | struct mtab {
22 | 	char	file[NAMSIZ];
23 | 	char	spec[NAMSIZ];
24 | } mtab[NMOUNT];
25 | 
26 | main(argc, argv)
27 | char **argv;
28 | {
29 | 	register struct mtab *mp;
30 | 	register char *p1, *p2;
31 | 	int mf;
32 | 
33 | 	sync();
34 | 	mf = open("/etc/mtab", 0);
35 | 	read(mf, mtab, NMOUNT*2*NAMSIZ);
36 | 	if(argc != 2) {
37 | 		printf("arg count\n");
38 | 		return;
39 | 	}
40 | 	if (umount(argv[1]) < 0) {
41 | 		perror("umount");
42 | 		return;
43 | 	}
44 | 	p1 = argv[1];
45 | 	while(*p1++)
46 | 		;
47 | 	p1--;
48 | 	while(*--p1 == '/')
49 | 		*p1 = '\0';
50 | 	while(p1 > argv[1] && *--p1 != '/')
51 | 		;
52 | 	if(*p1 == '/')
53 | 		p1++;
54 | 	argv[1] = p1;
55 | 	for (mp = mtab; mp < &mtab[NMOUNT]; mp++) {
56 | 		p1 = argv[1];
57 | 		p2 = &mp->spec[0];
58 | 		while (*p1++ == *p2)
59 | 			if (*p2++ == 0) {
60 | 				for (p1 = mp->file; p1 < &mp->file[NAMSIZ*2];)
61 | 					*p1++ = 0;
62 | 				mp = &mtab[NMOUNT];
63 | 				while ((--mp)->file[0] == 0);
64 | 				mf = creat("/etc/mtab", 0644);
65 | 				write(mf, mtab, (mp-mtab+1)*2*NAMSIZ);
66 | 				return;
67 | 			}
68 | 	}
69 | 	printf("%s not in mount table\n", argv[1]);
70 | }
71 | 
72 | 
73 | 
74 | 
75 | 
76 | 
77 | 
78 | 
79 | 
80 | 
81 | 
82 | 


--------------------------------------------------------------------------------
/usr/source/s/solloc/altch.s:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/salloc/altch.s
 3 | 

V6/usr/source/salloc/altch.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | .globl	alterchar
19 | .globl	plausible
20 | .globl	stats
21 | .globl	allocate, release
22 | .globl	copy
23 | .globl	bufchar, getbuf
24 | .globl	swap
25 | .globl	w, r, a, l
26 | .globl	w1, flag, u1, fixct
27 | /
28 | /	routine to rewrite the character pointer to by
29 | /	read pointer.  The read pointer is advanced.
30 | /	the string is extended if necessary.
31 | /	there is no error return.
32 | /
33 | /	movb	ch,r0
34 | /	mov	...,r1
35 | /	jsr	pc,alterchar
36 | /	mov	r1,...
37 | /
38 | alterchar:
39 | 	mov	r2,-(sp)
40 | 	mov	r1,-(sp)
41 | 	mov	r0,nchar
42 | 	jsr	pc,plausible
43 | 	inc	stats+8.
44 | 1:	cmp	r(r1),l(r1)	/W,L
45 | 	blt	3f
46 | 	mov	l(r1),r0
47 | 	inc	r0
48 | 	sub	a(r1),r0	/W-A+1
49 | 	jsr	pc,allocate
50 | 	mov	(sp),r0
51 | 	jsr	pc,copy
52 | 	jsr	pc,swap
53 | 	jsr	pc,release
54 | 	mov	(sp),r1
55 | /
56 | 3:	mov	r(r1),r0
57 | 	jsr	pc,bufchar
58 | 	bec	2f
59 | 	jsr	pc,getbuf
60 | 
61 | 2:	movb	nchar,(r0)
62 | 	mov	nchar,r0	/to preserve r0 for user
63 | 	inc	r(r1)
64 | 	mov	$1,w1(r2)
65 | 	cmp	r(r1),w(r1)
66 | 	ble	3f
67 | 	mov	r(r1),w(r1)
68 | 3:
69 | 	inc	flag
70 | 	bne	1f
71 | 	jsr	pc,fixct
72 | 	br	2f
73 | 1:
74 | 	mov	flag,u1(r2)
75 | 2:
76 | 	mov	(sp)+,r1
77 | 	mov	(sp)+,r2
78 | 	rts	pc
79 | /
80 | nchar:	.=.+2
81 | 
82 | 
83 | 
84 | 
85 | 
86 | 
87 | 
88 | 
89 | 
90 | 
91 | 
92 | 


--------------------------------------------------------------------------------
/usr/source/s/s5/run:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s5/run
 3 | 

V6/usr/source/s5/run

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | as mcrt0.s
19 | cmp a.out /lib/mcrt0.o
20 | cp a.out /lib/mcrt0.o
21 | as makdir.s; mv a.out makdir.o
22 | as mcount.s; mv a.out mcount.o
23 | as mdate.s; mv a.out mdate.o
24 | as mknod.s; mv a.out mknod.o
25 | as mount.s; mv a.out mount.o
26 | as nargs.s; mv a.out nargs.o
27 | as nice.s; mv a.out nice.o
28 | as nlist.s; mv a.out nlist.o
29 | as open.s; mv a.out open.o
30 | as pipe.s; mv a.out pipe.o
31 | as printf.s; mv a.out printf.o
32 | as prof.s; mv a.out prof.o
33 | as ptrace.s; mv a.out ptrace.o
34 | as putc.s; mv a.out putc.o
35 | as putchr.s; mv a.out putchr.o
36 | as read.s; mv a.out read.o
37 | as reset.s; mv a.out reset.o
38 | as sbrk.s; mv a.out sbrk.o
39 | as seek.s; mv a.out seek.o
40 | as setgid.s; mv a.out setgid.o
41 | as setuid.s; mv a.out setuid.o
42 | as signal.s; mv a.out signal.o
43 | as sleep.s; mv a.out sleep.o
44 | as stat.s; mv a.out stat.o
45 | as stime.s; mv a.out stime.o
46 | as stty.s; mv a.out stty.o
47 | as sync.s; mv a.out sync.o
48 | as time.s; mv a.out time.o
49 | as times.s; mv a.out times.o
50 | as umount.s; mv a.out umount.o
51 | as unlink.s; mv a.out unlink.o
52 | as wait.s; mv a.out wait.o
53 | as write.s; mv a.out write.o
54 | cc -c -O mon.c perror.c qsort.c
55 | cc -c -f -O rin.c
56 | ar r /lib/libc.a
57 | rm *.o
58 | 
59 | 
60 | 
61 | 
62 | 
63 | 
64 | 
65 | 
66 | 
67 | 
68 | 
69 | -------------------------------------------------------------------------------- /usr/source/s/s4/run: -------------------------------------------------------------------------------- 1 | 2 | V6/usr/source/s4/run 3 |

V6/usr/source/s4/run

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | as crt0.s
19 | cmp a.out /lib/crt0.o
20 | cp a.out /lib/crt0.o
21 | as fcrt0.s
22 | cmp a.out /lib/fcrt0.o
23 | cp a.out /lib/fcrt0.o
24 | as abort.s; mv a.out abort.o
25 | as abs.s; mv a.out abs.o
26 | as alloc.s; mv a.out alloc.o
27 | as atof.s; mv a.out atof.o
28 | as cerror.s; mv a.out cerror.o
29 | as chdir.s; mv a.out chdir.o
30 | as chmod.s; mv a.out chmod.o
31 | as chown.s; mv a.out chown.o
32 | as close.s; mv a.out close.o
33 | as creat.s; mv a.out creat.o
34 | as csv.s; mv a.out csv.o
35 | as dup.s; mv a.out dup.o
36 | as execl.s; mv a.out execl.o
37 | as execv.s; mv a.out execv.o
38 | as exit.s; mv a.out exit.o
39 | as ffltpr.s; mv a.out ffltpr.o
40 | as fltpr.s; mv a.out fltpr.o
41 | as fork.s; mv a.out fork.o
42 | as fstat.s; mv a.out fstat.o
43 | as getc.s; mv a.out getc.o
44 | as getchr.s; mv a.out getchr.o
45 | as getcsw.s; mv a.out getcsw.o
46 | as getgid.s; mv a.out getgid.o
47 | as getpid.s; mv a.out getpid.o
48 | as getuid.s; mv a.out getuid.o
49 | as gtty.s; mv a.out gtty.o
50 | as hmul.s; mv a.out hmul.o
51 | as kill.s; mv a.out kill.o
52 | as ladd.s; mv a.out ladd.o
53 | as ldfps.s; mv a.out ldfps.o
54 | as link.s; mv a.out link.o
55 | as locv.s; mv a.out locv.o
56 | as ltod.s; mv a.out ltod.o
57 | cc -c -O *.c
58 | ar r /lib/libc.a
59 | rm *.o
60 | 
61 | 
62 | 
63 | 
64 | 
65 | 
66 | 
67 | 
68 | 
69 | 
70 | 
71 | -------------------------------------------------------------------------------- /usr/sys/ken/malloc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Structure of the coremap and swapmap 3 | * arrays. Consists of non-zero count 4 | * and base address of that many 5 | * contiguous units. 6 | * (The coremap unit is 64 bytes, 7 | * the swapmap unit is 512 bytes) 8 | * The addresses are increasing and 9 | * the list is terminated with the 10 | * first zero count. 11 | */ 12 | struct map 13 | { 14 | char *m_size; 15 | char *m_addr; 16 | }; 17 | 18 | /* 19 | * Allocate size units from the given 20 | * map. Return the base of the allocated 21 | * space. 22 | * Algorithm is first fit. 23 | */ 24 | malloc(mp, size) 25 | struct map *mp; 26 | { 27 | register int a; 28 | register struct map *bp; 29 | 30 | for (bp = mp; bp->m_size; bp++) { 31 | if (bp->m_size >= size) { 32 | a = bp->m_addr; 33 | bp->m_addr =+ size; 34 | if ((bp->m_size =- size) == 0) 35 | do { 36 | bp++; 37 | (bp-1)->m_addr = bp->m_addr; 38 | } while ((bp-1)->m_size = bp->m_size); 39 | return(a); 40 | } 41 | } 42 | return(0); 43 | } 44 | 45 | /* 46 | * Free the previously allocated space aa 47 | * of size units into the specified map. 48 | * Sort aa into map and combine on 49 | * one or both ends if possible. 50 | */ 51 | mfree(mp, size, aa) 52 | struct map *mp; 53 | { 54 | register struct map *bp; 55 | register int t; 56 | register int a; 57 | 58 | a = aa; 59 | for (bp = mp; bp->m_addr<=a && bp->m_size!=0; bp++); 60 | if (bp>mp && (bp-1)->m_addr+(bp-1)->m_size == a) { 61 | (bp-1)->m_size =+ size; 62 | if (a+size == bp->m_addr) { 63 | (bp-1)->m_size =+ bp->m_size; 64 | while (bp->m_size) { 65 | bp++; 66 | (bp-1)->m_addr = bp->m_addr; 67 | (bp-1)->m_size = bp->m_size; 68 | } 69 | } 70 | } else { 71 | if (a+size == bp->m_addr && bp->m_size) { 72 | bp->m_addr =- size; 73 | bp->m_size =+ size; 74 | } else if (size) do { 75 | t = bp->m_addr; 76 | bp->m_addr = a; 77 | a = t; 78 | t = bp->m_size; 79 | bp->m_size = size; 80 | bp++; 81 | } while (size = t); 82 | } 83 | } -------------------------------------------------------------------------------- /usr/source/s/s2/wall.c: -------------------------------------------------------------------------------- 1 | 2 | V6/usr/source/s2/wall.c 3 |

V6/usr/source/s2/wall.c

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | char	mesg[3000];
19 | int	msize;
20 | struct
21 | {
22 | 	char	name[8];
23 | 	char	tty[2];
24 | 	int	time[2];
25 | 	int	junk;
26 | } utmp[50];
27 | 
28 | main(argc, argv)
29 | char *argv[];
30 | {
31 | 	register i, *p;
32 | 	int f;
33 | 
34 | 	f = open("/etc/utmp", 0);
35 | 	if(f < 0) {
36 | 		printf("utmp?\n");
37 | 		exit();
38 | 	}
39 | 	read(f, utmp, sizeof utmp);
40 | 	close(f);
41 | 	f = 0;
42 | 	if(argc >= 2) {
43 | 		f = open(argv[1], 0);
44 | 		if(f < 0) {
45 | 			printf("%s?\n", argv[1]);
46 | 			exit();
47 | 		}
48 | 	}
49 | 	while((i = read(f, &mesg[msize], sizeof mesg - msize)) > 0)
50 | 		msize =+ i;
51 | 	close(f);
52 | 	for(i=0; i<sizeof utmp/sizeof utmp[0]; i++) {
53 | 		p = &utmp[i];
54 | 		if(p->tty[0] == 0)
55 | 			continue;
56 | 		sleep(1);
57 | 		sendmes(p->tty[0]);
58 | 	}
59 | }
60 | 
61 | sendmes(tty)
62 | {
63 | 	register i;
64 | 	register char *s;
65 | 
66 | 	i = fork();
67 | 	if(i == -1) {
68 | 		printf("try again\n");
69 | 		return;
70 | 	}
71 | 	if(i)
72 | 		return;
73 | 	s = "/dev/ttyx";
74 | 	s[8] = tty;
75 | 	i = open(s, 1);
76 | 	if(i < 0) {
77 | 		printf("cannot open tty%c\n", tty);
78 | 		exit();
79 | 	}
80 | 	close(1);
81 | 	dup(i);
82 | 	printf("Broadcast Message ...\n\n");
83 | 	write(1, mesg, msize);
84 | 	exit();
85 | }
86 | 
87 | 
88 | 
89 | 
90 | 
91 | 
92 | 
93 | 
94 | 
95 | 
96 | 
97 | 


--------------------------------------------------------------------------------
/usr/source/s/s2/who.c:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s2/who.c
 3 | 

V6/usr/source/s2/who.c

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | /*
19 |  * who
20 |  */
21 | 
22 | int	fout;
23 | int	buf[256];
24 | 
25 | main(argc, argv)
26 | char **argv;
27 | {
28 | 	char *s, *cbuf;
29 | 	int n, fi, i;
30 | 	int tty;
31 | 	struct {
32 | 		char name[8];
33 | 		char tty;
34 | 		char pad1;
35 | 		int time[2];
36 | 		char pad2[2];
37 | 	} *p;
38 | 
39 | 	s = "/etc/utmp";
40 | 	if(argc == 2)
41 | 		s = argv[1];
42 | 	fi = open(s, 0);
43 | 	if(fi < 0) {
44 | 		write("cannot open wtmp\n", 17);
45 | 		exit();
46 | 	}
47 | 	fout = dup(1);
48 | 	close(1);
49 | 	if (argc==3)
50 | 		tty = ttyn(0);
51 | 
52 | loop:
53 | 	n = read(fi, buf, 512);
54 | 	if(n == 0) {
55 | 		flush();
56 | 		if (argc==3)
57 | 			write(fout, "Nobody.\n", 8);
58 | 		exit();
59 | 	}
60 | 
61 | 	p = &buf;
62 | 	for(p = &buf; (n =- 16)>=0; p++) {
63 | 		if (argc==3 && tty!=p->tty)
64 | 			continue;
65 | 		if(p->name[0] == '\0' && argc==1)
66 | 			continue;
67 | 		for(i=0; i<8; i++) {
68 | 			if(p->name[i] == '\0')
69 | 				p->name[i] = ' ';
70 | 			putchar(p->name[i]);
71 | 		}
72 | 		for(i=0; i<3; i++)
73 | 			putchar("tty"[i]);
74 | 		putchar(p->tty);
75 | 		cbuf = ctime(p->time);
76 | 		for(i=3; i<16; i++)
77 | 			putchar(cbuf[i]);
78 | 		putchar('\n');
79 | 		if (argc==3) {
80 | 			flush();
81 | 			exit();
82 | 		}
83 | 	}
84 | 	goto loop;
85 | }
86 | 
87 | 
88 | 
89 | 
90 | 
91 | 
92 | 
93 | 
94 | 
95 | 
96 | 
97 | 


--------------------------------------------------------------------------------
/usr/source/s/s2/sum.s:
--------------------------------------------------------------------------------
  1 | 
  2 | V6/usr/source/s2/sum.s
  3 | 

V6/usr/source/s2/sum.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
 18 | / sum -- check sum file
 19 | 
 20 | 	mov	(sp)+,r3
 21 | 	tst	(sp)+
 22 | loop:	dec	r3
 23 | 	bgt	1f
 24 | 	sys	exit
 25 | 1:
 26 | 	clr	bcnt
 27 | 	mov	(sp)+,0f
 28 | 	sys	open; 0:..; 0
 29 | 	bec	3f
 30 | 	mov	$1,r0
 31 | 	sys	write; 1f; 2f-1f
 32 | 	br	loop
 33 | 1:	<oprd\n>
 34 | 2:	.even
 35 | 3:	mov	r0,r1
 36 | 	clr	r5
 37 | 1:
 38 | 	mov	r1,r0
 39 | 	sys	read; buf; 512.
 40 | 	bes	err
 41 | 	tst	r0
 42 | 	beq	print
 43 | 	inc	bcnt
 44 | 	mov	$buf,r2
 45 | 2:
 46 | 	movb	(r2)+,r4
 47 | 	add	r4,r5
 48 | 	adc	r5
 49 | 	sob	r0,2b
 50 | 	br	1b
 51 | 
 52 | err:
 53 | 	mov	$1,r0
 54 | 	sys	write; 1f; 2
 55 | 
 56 | print:
 57 | 	jsr	pc,decml
 58 | 	mov	$1,r0
 59 | 	sys	write; bl; 1
 60 | 	mov	bcnt,r5
 61 | 	jsr	pc,decml
 62 | 	mov	$1,r0
 63 | 	sys	write; nl; 1
 64 | 	mov	r1,r0
 65 | 	sys	close
 66 | 	br	loop
 67 | 1:	<? >
 68 | nl:	<\n>
 69 | bl:	< >
 70 | 	.even
 71 | 
 72 | decml:
 73 | 	mov	r0,-(sp)
 74 | 	mov	r1,-(sp)
 75 | 	mov	r5,r1
 76 | 	jsr	pc,1f
 77 | 	mov	(sp)+,r1
 78 | 	mov	(sp)+,r0
 79 | 	rts	pc
 80 | 
 81 | 1:
 82 | 	clr	r0
 83 | 	dvd	$10.,r0
 84 | 	mov	r1,-(sp)
 85 | 	mov	r0,r1
 86 | 	beq	1f
 87 | 	jsr	pc,1b
 88 | 1:
 89 | 	mov	(sp)+,ch
 90 | 	add	$'0,ch
 91 | 	mov	$1,r0
 92 | 	sys	write; ch; 1
 93 | 	rts	pc
 94 | 
 95 | .bss
 96 | ch:	.=.+2
 97 | bcnt:	.=.+2
 98 | buf: .=.+512.
 99 | 
100 | 
101 | 
102 | 
103 | 
104 | 
105 | 
106 | 
107 | 
108 | 
109 | 
110 | 


--------------------------------------------------------------------------------
/usr/source/s/s1/cp.c:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s1/cp.c
 3 | 

V6/usr/source/s1/cp.c

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | /*
19 |  * cp oldfile newfile
20 |  */
21 | 
22 | main(argc,argv)
23 | char **argv;
24 | {
25 | 	static int buf[256];
26 | 	int fold, fnew, n;
27 | 	register char *p1, *p2, *bp;
28 | 	int mode;
29 | 
30 | 	if(argc != 3) {
31 | 		write(1, "Usage: cp oldfile newfile\n", 26);
32 | 		exit(1);
33 | 	}
34 | 	if((fold = open(argv[1], 0)) < 0) {
35 | 		write(1, "Cannot open old file.\n", 22);
36 | 		exit(1);
37 | 	}
38 | 	fstat(fold, buf);
39 | 	mode = buf[2];
40 | 	/* is target a directory? */
41 | 	if (stat(argv[2], buf+50)>=0 && (buf[52]&060000)==040000) {
42 | 		p1 = argv[1];
43 | 		p2 = argv[2];
44 | 		bp = buf+100;
45 | 		while(*bp++ = *p2++);
46 | 		bp[-1] = '/';
47 | 		p2 = bp;
48 | 		while(*bp = *p1++)
49 | 			if(*bp++ == '/')
50 | 				bp = p2;
51 | 		argv[2] = buf+100;
52 | 	}
53 | 	if (stat(argv[2], buf+50) >= 0) {
54 | 		if (buf[0]==buf[50] && buf[1]==buf[51]) {
55 | 			write(1, "Copying file to itself.\n", 24);
56 | 			exit(1);
57 | 		}
58 | 	}
59 | 	if ((fnew = creat(argv[2], mode)) < 0) {
60 | 		write(1, "Can't create new file.\n", 23);
61 | 		exit(1);
62 | 	}
63 | 	while(n = read(fold,  buf,  512)) {
64 | 	if(n < 0) {
65 | 		write(1, "Read error\n", 11);
66 | 		exit(1);
67 | 	} else
68 | 		if(write(fnew, buf, n) != n){
69 | 			write(1, "Write error.\n", 13);
70 | 			exit(1);
71 | 		}
72 | 	}
73 | 	exit(0);
74 | }
75 | 
76 | 
77 | 
78 | 
79 | 
80 | 
81 | 
82 | 
83 | 
84 | 
85 | 
86 | 


--------------------------------------------------------------------------------
/usr/source/s/s2/rm.c:
--------------------------------------------------------------------------------
  1 | main(argc, argv)
  2 | char *argv[];
  3 | {
  4 | 	char *arg;
  5 | 	int fflg, rflg;
  6 | 
  7 | 	fflg = 0;
  8 | 	rflg = 0;
  9 | 	while(--argc > 0) {
 10 | 
 11 | 		arg = *++argv;
 12 | 		if(arg[0] == '-') {
 13 | 			if(arg[1] == 'f') {
 14 | 				fflg++;
 15 | 				continue;
 16 | 			}
 17 | 			if(arg[1] == 'r') {
 18 | 				rflg++;
 19 | 				continue;
 20 | 			}
 21 | 		}
 22 | 
 23 | 		rm(arg, fflg, rflg);
 24 | 	}
 25 | }
 26 | 
 27 | struct stbuf	{
 28 | 	int dev;
 29 | 	int inum;
 30 | 	int mode;
 31 | 	char nlink;
 32 | 	char uid;
 33 | 	char gid;
 34 | 	char siz0;
 35 | 	char siz1;
 36 | 	int addr[8];
 37 | 	int adate[2];
 38 | 	int mdate[2];
 39 | 	};
 40 | 
 41 | rm(arg, fflg, rflg)
 42 | char arg[];
 43 | {
 44 | 	char *p;
 45 | 	int buf[20];
 46 | 	int i, b;
 47 | 
 48 | 	if(stat(arg, buf)) {
 49 | 		printf("%s: non existent\n", arg);
 50 | 		return;
 51 | 	}
 52 | 	if((buf->mode & 060000) == 040000)	{
 53 | 		if(rflg) {
 54 | 			i = fork();
 55 | 			if(i == -1) {
 56 | 				printf("%s: try again\n", arg);
 57 | 				return;
 58 | 			}
 59 | 			if(i) {
 60 | 				while(wait() != i);
 61 | 				return;
 62 | 			}
 63 | 			if(chdir(arg)) {
 64 | 				printf("%s: cannot chdir\n", arg);
 65 | 				exit();
 66 | 			}
 67 | 			p = 0;
 68 | 			execl("/etc/glob", "glob", "rm", "-r",
 69 | 				fflg? "-f": "*", fflg? "*": p, 0);
 70 | 			printf("%s: no glob\n", arg);
 71 | 			exit();
 72 | 		}
 73 | 		printf("%s: directory\n", arg);
 74 | 		return;
 75 | 	}
 76 | 
 77 | 	if(!fflg) {
 78 | 
 79 | 		if((getuid()&0377) == buf->uid)
 80 | 			b = 0200; else
 81 | 			b = 2;
 82 | 		if((buf->mode & b) == 0 && ttyn(0) != 'x') {
 83 | 			printf("%s: %o mode ", arg, buf->mode);
 84 | 			i = b = getchar();
 85 | 			i = b;
 86 | 			while(b != '\n' && b != '\0')
 87 | 				b = getchar();
 88 | 			if(i != 'y')
 89 | 				return;
 90 | 		}
 91 | 	}
 92 | 	if(unlink(arg))
 93 | 		printf("%s: not removed\n", arg);
 94 | }
 95 | 
 96 | putchar(c)
 97 | {
 98 | 	write(1, &c, 1);
 99 | }
100 | 
101 | getchar()
102 | {
103 | 	char c;
104 | 
105 | 	if(read(0, &c, 1) != 1) return(0);
106 | 	return(c);
107 | }
108 | 
109 | 
110 | 
111 | 
112 | 
113 | 
114 | 
115 | 
116 | 
117 | 
118 | 
119 | 


--------------------------------------------------------------------------------
/usr/source/s/s4/fltpr.s:
--------------------------------------------------------------------------------
  1 | 
  2 | V6/usr/source/s4/fltpr.s
  3 | 

V6/usr/source/s4/fltpr.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
 18 | / C library-- floating output
 19 | 
 20 | .globl	pfloat
 21 | .globl	pscien
 22 | .globl	fltused
 23 | 
 24 | .globl	_ndigit
 25 | .globl	ecvt
 26 | .globl	fcvt
 27 | 
 28 | fltused:		/ force loading
 29 | pfloat:
 30 | 	mov	r0,_ndigit
 31 | 	tst	r2
 32 | 	bne	1f
 33 | 	mov	$6,_ndigit
 34 | 1:
 35 | 	movf	(r4)+,fr0
 36 | 	jsr	pc,fcvt
 37 | 	tst	r1
 38 | 	beq	1f
 39 | 	movb	$'-,(r3)+
 40 | 1:
 41 | 	tst	r2
 42 | 	bgt	1f
 43 | 	movb	$'0,(r3)+
 44 | 1:
 45 | 	mov	r2,r1
 46 | 	ble	1f
 47 | 2:
 48 | 	movb	(r0)+,(r3)+
 49 | 	sob	r1,2b
 50 | 1:
 51 | 	mov	_ndigit,r1
 52 | 	beq	1f
 53 | 	movb	$'.,(r3)+
 54 | 1:
 55 | 	neg	r2
 56 | 	ble	1f
 57 | 2:
 58 | 	dec	r1
 59 | 	blt	1f
 60 | 	movb	$'0,(r3)+
 61 | 	sob	r2,2b
 62 | 1:
 63 | 	tst	r1
 64 | 	ble	2f
 65 | 1:
 66 | 	movb	(r0)+,(r3)+
 67 | 	sob	r1,1b
 68 | 2:
 69 | 	rts	pc
 70 | 
 71 | pscien:
 72 | 	mov	r0,_ndigit
 73 | 	tst	r2
 74 | 	bne	1f
 75 | 	mov	$6,_ndigit
 76 | 1:
 77 | 	movf	(r4)+,fr0
 78 | 	jsr	pc,ecvt
 79 | 	tst	r1
 80 | 	beq	1f
 81 | 	movb	$'-,(r3)+
 82 | 1:
 83 | 	movb	(r0)+,(r3)+
 84 | 	movb	$'.,(r3)+
 85 | 	mov	_ndigit,r1
 86 | 	dec	r1
 87 | 	ble	1f
 88 | 2:
 89 | 	movb	(r0)+,(r3)+
 90 | 	sob	r1,2b
 91 | 1:
 92 | 	movb	$'e,(r3)+
 93 | 	dec	r2
 94 | 	mov	r2,r1
 95 | 	bge	1f
 96 | 	movb	$'-,(r3)+
 97 | 	neg	r1
 98 | 	br	2f
 99 | 1:
100 | 	movb	$'+,(r3)+
101 | 2:
102 | 	clr	r0
103 | 	div	$10.,r0
104 | 	add	$'0,r0
105 | 	movb	r0,(r3)+
106 | 	add	$'0,r1
107 | 	movb	r1,(r3)+
108 | 	rts	pc
109 | 
110 | 
111 | 
112 | 
113 | 
114 | 
115 | 
116 | 
117 | 
118 | 
119 | 
120 | 


--------------------------------------------------------------------------------
/usr/sys/dmr/vs.c:
--------------------------------------------------------------------------------
  1 | /*
  2 |  * Screw Works interface via DC-11
  3 |  */
  4 |  
  5 | #include "../tty.h"
  6 |  
  7 | #define	VSADDR	0174150
  8 | #define	CDLEAD	01
  9 | #define	B1200	030
 10 | #define	STOP1	0400
 11 | #define	CLSEND	02
 12 | #define	RQSEND	01
 13 |  
 14 | #define	MAGIC_MAP 0377
 15 |  
 16 | struct {
 17 | 	int	vsrcsr;
 18 | 	int	vsrbuf;
 19 | 	int	vsxcsr;
 20 | 	int	vsxbuf;
 21 | };
 22 |  
 23 | struct {
 24 | 	struct	clist	iq;
 25 | 	struct	clist	oq;
 26 | } vs;
 27 |  
 28 | vsopen(dev)
 29 | {
 30 | 	VSADDR->vsrcsr = IENABLE|B1200|CDLEAD;
 31 | 	VSADDR->vsxcsr = STOP1|IENABLE|B1200;
 32 | 	vschar(0);
 33 | }
 34 |  
 35 | vsclose(dev)
 36 | {
 37 | 	vschar(0);
 38 | 	VSADDR->vsrcsr =& ~IENABLE;
 39 | 	while (getc(&vs.iq) >= 0);
 40 | }
 41 |  
 42 | vswrite(dev)
 43 | {
 44 | 	register int count, c;
 45 |  
 46 | 	count = 0;
 47 | 	while ((c=cpass()) >= 0) {
 48 | 		if (--count <= 0) {
 49 | 			count = 60;
 50 | 			vschar(0);
 51 | 		}
 52 | 		vschar(c);
 53 | 	}
 54 | 	vschar(0);
 55 | }
 56 |  
 57 | vschar(c)
 58 | {
 59 |  
 60 | 	c =^ MAGIC_MAP;
 61 | 	spl5();
 62 | 	while (vs.oq.c_cc > 60) {
 63 | 		vsxintr();
 64 | 		sleep(&vs.oq, TTIPRI);
 65 | 	}
 66 | 	putc(c, &vs.oq);
 67 | 	vsxintr();
 68 | 	spl0();
 69 | }
 70 |  
 71 | vsxintr()
 72 | {
 73 | 	static lchar;
 74 | 	register c;
 75 | 	register int *xcsr;
 76 |  
 77 | 	xcsr = &VSADDR->vsxcsr;
 78 | 	if (*xcsr&DONE) {
 79 | 		if (lchar==MAGIC_MAP) {
 80 | 			*xcsr =& ~RQSEND;
 81 | 			lchar = 0;
 82 | 			if (vs.oq.c_cc==0)
 83 | 				goto wake;
 84 | 		}
 85 | 		if ((*xcsr&CLSEND) == 0) {
 86 | 			*xcsr =& ~RQSEND;
 87 | 			*xcsr =| RQSEND;
 88 | 			if ((*xcsr&CLSEND) == 0)
 89 | 				goto wake;
 90 | 		}
 91 | 		if ((c = getc(&vs.oq)) >= 0)
 92 | 			VSADDR->vsxbuf = lchar = c;
 93 | 		if (vs.oq.c_cc <= 15)
 94 | 	    wake:
 95 | 			wakeup(&vs.oq);
 96 | 	}
 97 | }
 98 |  
 99 | vsread(dev)
100 | {
101 | 	register int c;
102 |  
103 | 	spl5();
104 | 	while ((c = getc(&vs.iq)) < 0)
105 | 		sleep(&vs.iq, TTIPRI);
106 | 	spl0();
107 | 	passc("?0*#?546?213?879?"[c&017]);
108 | }
109 |  
110 | vsrintr()
111 | {
112 | 	register int c;
113 |  
114 | 	c = VSADDR->vsrbuf;
115 | 	if (vs.iq.c_cc<=10)
116 | 		putc(c, &vs.iq);
117 | 	wakeup(&vs.iq);
118 | }


--------------------------------------------------------------------------------
/usr/source/s/s2/pwd.c:
--------------------------------------------------------------------------------
 1 | 
 2 | V6/usr/source/s2/pwd.c
 3 | 

V6/usr/source/s2/pwd.c

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
18 | char dot[] ".";
19 | char dotdot[] "..";
20 | char root[] "/";
21 | char name[512];
22 | int file, off -1;
23 | struct statb {int devn, inum, i[18];}x;
24 | struct entry { int jnum; char name[16];}y;
25 | 
26 | main() {
27 | 	int n;
28 | 
29 | loop0:
30 | 	stat(dot, &x);
31 | 	if((file = open(dotdot,0)) < 0) prname();
32 | loop1:
33 | 	if((n = read(file,&y,16)) < 16) prname();
34 | 	if(y.jnum != x.inum)goto loop1;
35 | 	close(file);
36 | 	if(y.jnum == 1) ckroot();
37 | 	cat();
38 | 	chdir(dotdot);
39 | 	goto loop0;
40 | }
41 | ckroot() {
42 | 	int i, n;
43 | 
44 | 	if((n = stat(y.name,&x)) < 0) prname();
45 | 	i = x.devn;
46 | 	if((n = chdir(root)) < 0) prname();
47 | 	if((file = open(root,0)) < 0) prname();
48 | loop:
49 | 	if((n = read(file,&y,16)) < 16) prname();
50 | 	if(y.jnum == 0) goto loop;
51 | 	if((n = stat(y.name,&x)) < 0) prname();
52 | 	if(x.devn != i) goto loop;
53 | 	x.i[0] =& 060000;
54 | 	if(x.i[0] != 040000) goto loop;
55 | 	if(y.name[0]=='.')if(((y.name[1]=='.') && (y.name[2]==0)) ||
56 | 				(y.name[1] == 0)) goto pr;
57 | 	cat();
58 | pr:
59 | 	write(1,root,1);
60 | 	prname();
61 | }
62 | prname() {
63 | 	if(off<0)off=0;
64 | 	name[off] = '\n';
65 | 	write(1,name,off+1);
66 | 	exit();
67 | }
68 | cat() {
69 | 	int i, j;
70 | 
71 | 	i = -1;
72 | 	while(y.name[++i] != 0);
73 | 	if((off+i+2) > 511) prname();
74 | 	for(j=off+1; j>=0; --j) name[j+i+1] = name[j];
75 | 	off=i+off+1;
76 | 	name[i] = root[0];
77 | 	for(--i; i>=0; --i) name[i] = y.name[i];
78 | }
79 | 
80 | 
81 | 
82 | 
83 | 
84 | 
85 | 
86 | 
87 | 
88 | 
89 | 
90 | 


--------------------------------------------------------------------------------
/usr/source/s/s1/form2.s:
--------------------------------------------------------------------------------
  1 | 
  2 | V6/usr/source/s1/form2.s
  3 | 

V6/usr/source/s1/form2.s

4 |
5 | 6 | Find at most 13 | related files.
14 | 15 | including files from this version of Unix. 16 |

17 |
 18 | /	scan
 19 | /	r1 = pointer to input header
 20 | /	r0 = pointer to output header
 21 | /	switch = 0 real output
 22 | /		not 0  output to r0
 23 | scan:
 24 | 	mov	r0,-(sp)
 25 | 	mov	r1,-(sp)
 26 | 
 27 | 1:
 28 | 	mov	(sp),r1
 29 | 	jsr	pc,getchar
 30 | 	bes	5f
 31 | 	cmpb	r0,$'\\
 32 | 	beq	3f
 33 | 	cmpb	r0,$'\[
 34 | 	beq	4f
 35 | 	cmpb	r0,$'\{
 36 | 	beq	4f
 37 | 	cmpb	r0,$'\]
 38 | 	beq	1f
 39 | 	cmpb	r0,$'\}
 40 | 	beq	7f
 41 | 	cmpb	r0,$'\n
 42 | 	bne	6f
 43 | 	jsr	pc,lookchar
 44 | 	bes	5f
 45 | 	movb	$'\n,r0
 46 | 6:
 47 | 	tst	switch
 48 | 	beq	2f
 49 | 	mov	2(sp),r1
 50 | 	jsr	pc,putchar
 51 | 	br	1b
 52 | 2:
 53 | 	jsr	r5,putc
 54 | 	br	1b
 55 | 3:
 56 | 	jsr	pc,getchar
 57 | 	br	6b
 58 | /	have [ or {
 59 | 4:
 60 | 	mov	r(r1),-(sp)
 61 | 	jsr	pc,getchar
 62 | 	bes	1f
 63 | 	cmpb	r0,$'0
 64 | 	blt	4f
 65 | 	cmpb	r0,$'9
 66 | 	bgt	4f
 67 | 	jsr	pc,getchar
 68 | 	cmpb	r0,$'\]
 69 | 	beq	3f
 70 | 	cmpb	r0,$'\}
 71 | 	beq	3f
 72 | 
 73 | 4:
 74 | 	mov	(sp)+,r(r1)
 75 | 	mov	2(sp),r0
 76 | 	jsr	pc,esub
 77 | 	mov	r1,(sp)
 78 | 	mov	r0,2(sp)
 79 | 	br	1b
 80 | 
 81 | /	have arg
 82 | 3:
 83 | 	tst	switch
 84 | 	beq	2f
 85 | 	mov	opointer,r1
 86 | 	mov	4(sp),r0
 87 | 	jsr	pc,putword
 88 | 	mov	2(sp),r1
 89 | 2:
 90 | 	mov	(sp)+,r(r1)
 91 | 	jsr	pc,getchar
 92 | 	inc	r(r1)	/skip ]
 93 | 	jsr	pc,earg
 94 | 	br	1b
 95 | 
 96 | 5:
 97 | 	tst	argf
 98 | 	bne	1f
 99 | 	mov	ipointer,r1
100 | 	jsr	pc,pop
101 | 	bes	1f
102 | 	mov	r0,(sp)
103 | 	br	1b
104 | 7:
105 | 	inc	curlyf
106 | 1:
107 | 	mov	(sp)+,r1
108 | 	mov	(sp)+,r0
109 | 	rts	pc
110 | 
111 | 
112 | 
113 | 
114 | 
115 | 
116 | 
117 | 
118 | 
119 | 
120 | 
121 | 


--------------------------------------------------------------------------------