├── .gitignore ├── .gitmodules ├── CREDITS ├── LICENSE ├── LICENSE.Apout ├── Makefile ├── README.md ├── boot ├── README ├── bos ├── installboot ├── m792low.load ├── m792low.s ├── m792uv1.load ├── m792uv1.s ├── simh.cfg └── simh_cold.cfg ├── build └── Makefile ├── docs ├── PreliminaryUnixImplementationDocument_Jun72.pdf └── edtut.pdf ├── fs ├── README.md ├── new │ ├── etc │ │ ├── init │ │ ├── passwd │ │ └── uids │ └── usr │ │ └── boot │ │ ├── bos.s │ │ ├── msys.s │ │ ├── run │ │ └── wunix ├── root │ ├── bin │ │ ├── : │ │ ├── ar │ │ ├── as │ │ ├── bas │ │ ├── cal │ │ ├── cat │ │ ├── cc │ │ ├── chball │ │ ├── check │ │ ├── chmod │ │ ├── chown │ │ ├── cmp │ │ ├── cp │ │ ├── date │ │ ├── db │ │ ├── dc │ │ ├── df │ │ ├── ds │ │ ├── dsw │ │ ├── du │ │ ├── echo │ │ ├── ed │ │ ├── exit │ │ ├── fc │ │ ├── find │ │ ├── form │ │ ├── goto │ │ ├── if │ │ ├── ld │ │ ├── ln │ │ ├── login │ │ ├── ls │ │ ├── mail │ │ ├── maki │ │ ├── mesg │ │ ├── mkdir │ │ ├── mv │ │ ├── nm │ │ ├── od │ │ ├── pr │ │ ├── rew │ │ ├── rm │ │ ├── rmdir │ │ ├── roff │ │ ├── sh │ │ ├── size │ │ ├── skip │ │ ├── sort │ │ ├── stat │ │ ├── strip │ │ ├── stty │ │ ├── su │ │ ├── sum │ │ ├── tap │ │ ├── tm │ │ ├── tty │ │ ├── un │ │ ├── wc │ │ ├── who │ │ └── write │ ├── etc │ │ ├── as2 │ │ ├── getty │ │ ├── glob │ │ ├── init │ │ ├── msh │ │ ├── passwd │ │ ├── std0 │ │ ├── suftab │ │ └── uids │ ├── tmp │ │ ├── etma │ │ ├── ttmp │ │ └── utmp │ └── usr │ │ └── .placeholder └── usr │ ├── boot │ ├── bos.s │ ├── msys.s │ ├── msys2.s │ ├── run │ └── unix.out │ ├── fort │ ├── fc1 │ ├── fc2 │ ├── fc3 │ └── fc4 │ ├── jack │ ├── a.out │ └── x.f │ ├── ken │ └── maki.s │ ├── lib │ ├── bilib.a │ ├── c0 │ ├── c1 │ ├── filib.a │ ├── liba.a │ ├── libb.a │ ├── libc.a │ └── libf.a │ ├── sys │ ├── a.out │ ├── core │ └── maki.s │ └── x ├── notes ├── TODO.txt ├── machine.txt ├── notes.txt ├── people.txt ├── s2-sh.s └── s2files.txt ├── pages ├── e00-01 ├── e00-02 ├── e00-03 ├── e00-04 ├── e00-05 ├── e00-06 ├── e00-07 ├── e00-08 ├── e00-09 ├── e00-10 ├── e01-01 ├── e01-02 ├── e01-03 ├── e01-04 ├── e01-05 ├── e01-06 ├── e01-07 ├── e01-08 ├── e01-09 ├── e01-10 ├── e02-01 ├── e02-02 ├── e02-03 ├── e02-04 ├── e02-05 ├── e02-06 ├── e02-07 ├── e02-08 ├── e02-09 ├── e02-10 ├── e03-01 ├── e03-02 ├── e03-03 ├── e03-04 ├── e04-01 ├── e04-02 ├── e04-03 ├── e04-04 ├── e04-05 ├── e04-06 ├── e04-07 ├── e05-01 ├── e05-02 ├── e05-03 ├── e05-04 ├── e05-05 ├── e05-06 ├── e06-01 ├── e06-02 ├── e06-03 ├── e06-04 ├── e06-05 ├── e06-06 ├── e07-01 ├── e07-02 ├── e07-03 ├── e07-04 ├── e07-05 ├── e07-06 ├── e07-07 ├── e07-08 ├── e08-01 ├── e08-02 ├── e08-03 ├── e08-04 ├── e08-05 ├── e08-06 ├── e08-07 ├── e08-08 ├── e08-09 ├── e09-01 ├── e09-02 ├── e09-03 ├── e09-04 ├── e09-05 ├── e09-06 ├── e09-07 ├── e09-08 ├── e10-01 ├── e10-02 ├── e11-01 ├── e11-02 ├── e11-03 ├── e11-04 ├── e11-05 ├── e11-06 ├── e11-07 ├── e12-01 ├── e12-02 ├── e12-03 └── e12-04 ├── patches ├── cold.patch ├── core │ ├── aout407.patch │ ├── ecore.patch │ ├── fastout.patch │ ├── initorig.patch │ ├── shell.patch │ ├── shorig.patch │ ├── upcase.patch │ ├── v2_as.patch │ └── vec0407.patch ├── fixV7div.patch ├── notes.txt └── shell-s2.patch ├── simh.cfg ├── src ├── README.md ├── c │ ├── README.md │ ├── c00.c │ ├── c01.c │ ├── c02.c │ ├── c03.c │ ├── c0t.s │ ├── c10.c │ ├── c11.c │ ├── c1t.s │ ├── cc.c │ ├── cctab.s │ ├── cvopt.c │ ├── efftab.s │ ├── fptab.s │ ├── mak │ ├── regtab.s │ ├── sptab.s │ └── v1mak ├── cmd │ ├── acct.s │ ├── ar.s │ ├── as11.s │ ├── as12.s │ ├── as13.s │ ├── as14.s │ ├── as15.s │ ├── as16.s │ ├── as17.s │ ├── as18.s │ ├── as19.s │ ├── as21.s │ ├── as22.s │ ├── as23.s │ ├── as24.s │ ├── as25.s │ ├── as26.s │ ├── as27.s │ ├── as28.s │ ├── as29.s │ ├── bas0.s │ ├── bas1.s │ ├── cat.s │ ├── cc.c │ ├── chmod.s │ ├── chown.s │ ├── cmp.s │ ├── colon.s │ ├── cp.c │ ├── date.s │ ├── db1.s │ ├── db2.s │ ├── db3.s │ ├── db4.s │ ├── dc1.s │ ├── dc2.s │ ├── dc3.s │ ├── dc4.s │ ├── dc5.s │ ├── df.s │ ├── dsw.s │ ├── dusg.s │ ├── ed2.s │ ├── ed3.s │ ├── exit.c │ ├── fc.c │ ├── fed1.s │ ├── fed2.s │ ├── fed3.s │ ├── form1.s │ ├── form2.s │ ├── form3.s │ ├── form4.s │ ├── form5.s │ ├── form6.s │ ├── fstrip.s │ ├── getty.s │ ├── glob.c │ ├── goto.c │ ├── if.c │ ├── init.s │ ├── ld1.s │ ├── ld2.s │ ├── ldx.s │ ├── ln.s │ ├── login.s │ ├── ls.s │ ├── mak │ └── unknown.c └── lib │ ├── bsw.s │ ├── chdir.s │ ├── chmod.s │ ├── chown.s │ ├── close.s │ ├── creat.s │ ├── crt0.s │ ├── ctime.s │ ├── execl.s │ ├── execv.s │ ├── exit.s │ ├── fork.s │ ├── fstat.s │ ├── getchr.s │ ├── getuid.s │ ├── gtty.s │ ├── intr.s │ ├── link.s │ ├── makdir.s │ ├── open.s │ ├── printf.c │ ├── printf.s │ ├── putchr.s │ ├── read.s │ ├── seek.s │ ├── setuid.s │ ├── stat.s │ ├── stty.s │ ├── switch.s │ ├── time.s │ ├── unlink.s │ ├── wait.s │ └── write.s └── tools ├── Makefile ├── apout ├── CHANGES ├── LIMITATIONS ├── Makefile ├── README.md ├── TODO ├── aout.c ├── aout.h ├── apout.1 ├── branch.c ├── bsd_ioctl.c ├── bsd_signal.c ├── bsdtrap.c ├── bsdtrap.h ├── cpu.c ├── defines.h ├── double.c ├── ea.c ├── fp.c ├── itab.c ├── ke11a.c ├── magic.c ├── main.c ├── single.c ├── v1trap.c ├── v1trap.h ├── v7trap.c └── v7trap.h ├── as ├── assemv2 ├── conv2.c ├── disaout ├── Makefile ├── README ├── aout.c ├── aout.h ├── magic.c ├── main.c ├── opset.c ├── symbols.c └── syscalls.c ├── fixaout.py ├── imgbuild ├── mkfs.c ├── mktape.py ├── ml.c ├── rebuild ├── rebuild-split └── tap /.gitignore: -------------------------------------------------------------------------------- 1 | # intermediate files 2 | build/*.s 3 | build/*.dsk 4 | build/*.clean 5 | build/*.orig 6 | build/*.0405 7 | build/cleansrc 8 | build/patched 9 | build/protofs 10 | build/root/ 11 | build/unix 12 | build/usr/ 13 | build/usyms 14 | *.dSYM 15 | 16 | # installed images 17 | images 18 | 19 | # tools 20 | tools/apout/apout 21 | tools/apout/*.o 22 | tools/mkfs 23 | tools/ml 24 | tools/pdp11 25 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "tools/simh"] 2 | path = tools/simh 3 | url = https://github.com/open-simh/simh 4 | -------------------------------------------------------------------------------- /CREDITS: -------------------------------------------------------------------------------- 1 | Many thanks to everyone who participated in the restoration by OCRing 2 | text, proof reading the OCRs, debugging and organizing the results. 3 | 4 | Johan Beiser 5 | Tim Bradshaw 6 | Brantley Coile 7 | Grey David 8 | Alex Garbutt 9 | Hellwig Geisse 10 | Cyrille Lefevre 11 | Ralph Logan 12 | James Markevitch 13 | Doug Merritt 14 | Tim Newsham 15 | Brad Parker 16 | Warren Toomey 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) Caldera International Inc. 2001-2002. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | Redistributions of source code and documentation must retain the above 7 | copyright notice, this list of conditions and the following disclaimer. 8 | Redistributions in binary form must reproduce the above copyright notice, 9 | this list of conditionsand the following disclaimer in the documentation 10 | and/or other materials provided with the distribution. 11 | All advertising materials mentioning features or use of this software must 12 | display the following acknowledgement: 13 | 14 | This product includes software developed or owned by Caldera 15 | International, Inc. 16 | 17 | Neither the name of Caldera International, Inc. nor the names of other 18 | contributors may be used to endorse or promote products derived from this 19 | software without specific prior written permission. 20 | 21 | USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA INTERNATIONAL, 22 | INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 23 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 24 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CALDERA 25 | INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, 26 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 28 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OFLIABILITY, 29 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 30 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 31 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | -------------------------------------------------------------------------------- /LICENSE.Apout: -------------------------------------------------------------------------------- 1 | The Apout simulator is copyrighted by Warren Toomey and is protected by the 2 | following notice: 3 | 4 | Copyright (C) 1995-2002, Warren Toomey. 5 | 6 | Permission to use, copy, modify, and distribute this software and its 7 | documentation for any purpose and without fee is hereby granted, provided 8 | that the above copyright notice appear in all copies. Warren Toomey 9 | makes no representations about the suitability of this software for any 10 | purpose. It is provided "as is" without expressed or implied warranty. 11 | 12 | The parts of Apout that deal with PDP-11 instruction emulation are derived 13 | from the PDP-11 simulator written by Eric A. Edwards and are protected by 14 | the following notice. 15 | 16 | Copyright (C) 1994, Eric A. Edwards. 17 | 18 | Permission to use, copy, modify, and distribute this software and its 19 | documentation for any purpose and without fee is hereby granted, provided 20 | that the above copyright notice appear in all copies. Eric A. Edwards 21 | makes no representations about the suitability of this software for any 22 | purpose. It is provided "as is" without expressed or implied warranty. 23 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | $(MAKE) -C tools 3 | $(MAKE) -C build install 4 | 5 | run: all 6 | tools/pdp11 simh.cfg 7 | 8 | clean: 9 | $(MAKE) -C build clean 10 | 11 | distclean: clean 12 | $(MAKE) -C tools clean 13 | $(MAKE) -C build distclean 14 | -------------------------------------------------------------------------------- /boot/README: -------------------------------------------------------------------------------- 1 | UNIX V1 bootstrap 2 | 3 | The UNIX V1 bootstrap procedure is described in UNIX_ProgammersManual_Nov71.pdf, 4 | section BOOT PROCEDURES (VII). 5 | 6 | To install the bootstrap and kernel, prior to running the V1 system, use 7 | the boot/installboot command. This will install the bos program as well 8 | as the recently-built kernel from build/loadfile into the warm boot area 9 | of the rf0 disk: 10 | 11 | boot/installboot 12 | 13 | The system can be warm booted with: 14 | 15 | tools/pdp11 boot/simh.cfg 16 | 17 | NOTE: For using kernels built using the V2 assembler, all of the following 18 | should refer to msys2, instead of msys. 19 | 20 | Alternatively, everything can be installed while running under the V1 system 21 | using the following procedure: 22 | 23 | First, build the support programs: bos and msys 24 | 25 | chdir /usr/boot 26 | sh run 27 | 28 | Install the bootstrap and unix: 29 | 30 | msys b bos 31 | msys u wunix 32 | 33 | If you build a kernel under V1, then you can install it into the warm 34 | boot area with: 35 | 36 | msys u name_of_kernel 37 | 38 | You can install it into the cold boot area (such as for testing) with: 39 | 40 | msys 1 name_of_kernel 41 | 42 | The default installation does not copy an image into the cold boot area. 43 | However, if the cold boot area is being used for testing new kernels, 44 | then the kernel can be bootstrapped using: 45 | 46 | tools/pdp11 boot/simh_cold.cfg 47 | 48 | NOTE: the 32W bootstrap normally resides at location 173700, but because the 49 | simulator does not have memory at that location, the current bootstrap is 50 | copied into 073700 in the simulator. This does not change the behavior at all. 51 | -------------------------------------------------------------------------------- /boot/bos: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/boot/bos -------------------------------------------------------------------------------- /boot/installboot: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | RF0IMAGE=rf0.dsk 4 | KERNEL=build/loadfile 5 | BOS=boot/bos 6 | 7 | if [ ! -f $KERNEL ] 8 | then echo "You must build the kernel, $KERNEL, before you can install" 9 | echo "the bootstrap." 10 | exit 1 11 | fi 12 | 13 | # Install bos 32KW below the top of the rf0 image 14 | # 15 | dd if=$BOS of=$RF0IMAGE bs=512 seek=960 16 | 17 | # Install Unix in the warm boot area, 31KW below the top of the 18 | # rf0 image. Because the kernel is in simh load format, the first 19 | # 6 bytes are skipped and the following 16K byte are copied onto 20 | # the rf0 disk. 21 | # 22 | dd if=$KERNEL bs=1 skip=6 count=16384 | dd of=$RF0IMAGE bs=512 seek=964 23 | -------------------------------------------------------------------------------- /boot/m792low.load: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/boot/m792low.load -------------------------------------------------------------------------------- /boot/m792low.s: -------------------------------------------------------------------------------- 1 | / UNIX bootstrap ROM, based on BOOT PROCEDURES (VII) 11/3/71 2 | 3 | . = 73700 4 | 5 | / 173700 -- load bos from 1700000 of rf0 (RF11) 6 | 7 | mov $177472,r0 8 | mov $3,-(r0) / rf11.dae.ta[6:5] = 3 9 | mov $140000,-(r0) / rf11.dar = 140000 10 | mov $54000,-(r0) / rf11.cma = 54000 11 | mov $-2000,-(r0) / rf11.wc = -2000 (1K words) 12 | mov $5,-(r0) / rf11.dcs = read,go 13 | tstb (r0) / done? 14 | bge .-2 / no, loop 15 | jmp *$54000 / jump to bos 16 | 17 | / 173740 -- load from tap0 (TC11 DECtape) 18 | 19 | mov $177350,r0 20 | clr -(r0) / tc11.tcba = 0 21 | mov r0,-(r0) / tc11.tcwc = 177346 (282. bytes) 22 | mov $3,-(r0) / tc11.tccm = rnum,do 23 | tstb (r0) / done? 24 | bge .-2 / no, loop 25 | tst *$177350 / block 0? 26 | bne . / no, loop forever 27 | movb $5,(r0) / tc11.tccm = rdata,do 28 | tstb (r0) / done? 29 | bge .-2 / no, loop 30 | clr pc / jump to location 0 31 | -------------------------------------------------------------------------------- /boot/m792uv1.load: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/boot/m792uv1.load -------------------------------------------------------------------------------- /boot/m792uv1.s: -------------------------------------------------------------------------------- 1 | / UNIX bootstrap ROM, based on BOOT PROCEDURES (VII) 11/3/71 2 | 3 | . = 173700 4 | 5 | / 173700 -- load bos from 1700000 of rf0 (RF11) 6 | 7 | mov $177472,r0 8 | mov $3,-(r0) / rf11.dae.ta[6:5] = 3 9 | mov $140000,-(r0) / rf11.dar = 140000 10 | mov $54000,-(r0) / rf11.cma = 54000 11 | mov $-2000,-(r0) / rf11.wc = -2000 (1K words) 12 | mov $5,-(r0) / rf11.dcs = read,go 13 | tstb (r0) / done? 14 | bge .-2 / no, loop 15 | jmp *$54000 / jump to bos 16 | 17 | / 173740 -- load from tap0 (TC11 DECtape) 18 | 19 | mov $177350,r0 20 | clr -(r0) / tc11.tcba = 0 21 | mov r0,-(r0) / tc11.tcwc = 177346 (282. bytes) 22 | mov $3,-(r0) / tc11.tccm = rnum,do 23 | tstb (r0) / done? 24 | bge .-2 / no, loop 25 | tst *$177350 / block 0? 26 | bne . / no, loop forever 27 | movb $5,(r0) / tc11.tccm = rdata,do 28 | tstb (r0) / done? 29 | bge .-2 / no, loop 30 | clr pc / jump to location 0 31 | -------------------------------------------------------------------------------- /boot/simh.cfg: -------------------------------------------------------------------------------- 1 | #!tools/pdp11 2 | set cpu 11/20 3 | set cpu 32K 4 | set rk0 enabled 5 | att rk0 rk0.dsk 6 | set rf 2p 7 | set rf enabled 8 | attach rf rf0.dsk 9 | set tc enabled 10 | att tc tape 11 | set hk disabled 12 | set rha disabled 13 | set tm disabled 14 | set rx disabled 15 | set rl disabled 16 | set tq disabled 17 | set tc enabled 18 | set rf enabled 19 | set ke enabled 20 | set cpu history=1000 21 | load boot/m792low.load 22 | d sr 173700 23 | go 73700 24 | -------------------------------------------------------------------------------- /boot/simh_cold.cfg: -------------------------------------------------------------------------------- 1 | #!tools/pdp11 2 | set cpu 11/20 3 | set cpu 32K 4 | set rk0 enabled 5 | att rk0 rk0.dsk 6 | set rf 2p 7 | set rf enabled 8 | attach rf rf0.dsk 9 | set tc enabled 10 | att tc tape 11 | set hk disabled 12 | set rha disabled 13 | set tm disabled 14 | set rx disabled 15 | set rl disabled 16 | set tq disabled 17 | set tc enabled 18 | set rf enabled 19 | set ke enabled 20 | set cpu history=1000 21 | load boot/m792low.load 22 | d sr 1 23 | go 73700 24 | -------------------------------------------------------------------------------- /docs/PreliminaryUnixImplementationDocument_Jun72.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/docs/PreliminaryUnixImplementationDocument_Jun72.pdf -------------------------------------------------------------------------------- /docs/edtut.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/docs/edtut.pdf -------------------------------------------------------------------------------- /fs/new/etc/init: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/new/etc/init -------------------------------------------------------------------------------- /fs/new/etc/passwd: -------------------------------------------------------------------------------- 1 | root::0:/: 2 | eroot::0:/:/bin/ed 3 | sys::1:/usr/sys: 4 | bin::3:/bin: 5 | adm::3:/usr/adm: 6 | s1::3:/usr/s1: 7 | s2::3:/usr/s2: 8 | jfo::4:/usr/jfo: 9 | ken::6:/usr/ken: 10 | dmr::7:/usr/dmr: 11 | jack::10:/usr/jack: 12 | peter::11:/usr/peter: 13 | jay::12:/usr/jay: 14 | bob::13:/usr/bob: 15 | sun::14:/usr/sun: 16 | lee::15:/usr/lee: 17 | -------------------------------------------------------------------------------- /fs/new/etc/uids: -------------------------------------------------------------------------------- 1 | root:0 2 | sys:1 3 | bin:3 4 | adm:3 5 | jfo:4 6 | ken:6 7 | dmr:7 8 | jack:10 9 | peter:11 10 | jay:12 11 | bob:13 12 | sun:14 13 | lee:15 14 | -------------------------------------------------------------------------------- /fs/new/usr/boot/bos.s: -------------------------------------------------------------------------------- 1 | / bos -- UNIX V1 bootstrap 2 | / 3 | / re-creation, based on description in UNIX_ProgammersManual_Nov71.pdf, 4 | / page 7-06, BOOT PROCEDURES (VII) 5 | / 5/6/08 jam@magic.com 6 | / 7 | / M792 bootstrap loads this into core at 54000 8 | / 9 | / Behavior depends on switch register: 10 | / 173700 or 11 | / 073700 Read Warm UNIX from RF into core location 0 and jump to 400 12 | / 1 Read Cold UNIX from RF into core location 0 and jump to 400 13 | / 2 Read unassigned 3K program into core location 0 and jump to 400 14 | / 10 Dump 12K words from core location 0 onto DECtape drive 7 15 | / 0 UNIMPLEMENTED -- should be read UNIX binary paper tape 16 | 17 | csw = 177570 18 | 19 | /. = 54000 20 | 21 | mov $177472,r1 22 | mov *$csw,r0 23 | cmp r0,$173700 24 | beq warm 25 | cmp r0,$73700 26 | bne 1f 27 | warm: 28 | / x73700 = Warm UNIX 29 | mov $3,-(r1) / rf0 dae = track number high bits 30 | mov $142000,-(r1) / rf0 dar = 256KW - 15KW 31 | clr -(r1) / rf0 cma = 0 32 | mov $-14000,-(r1) / rf0 wc = 6KW 33 | loadrf: 34 | mov $5,-(r1) / rf0 dcs = read 35 | tstb (r1) / rf0 done? 36 | bge .-2 / no, loop 37 | jmp *$400 / jump to loaded code 38 | 39 | 1: 40 | cmp r0,$1 41 | bne 1f 42 | 43 | / 0 = Cold UNIX 44 | mov $3,-(r1) / rf0 dae = track number high bits 45 | mov $156000,-(r1) / rf0 dar = 256KW - 9KW 46 | clr -(r1) / rf0 cma = 0 47 | mov $-14000,-(r1) / rf0 wc = 6KW 48 | br loadrf 49 | 50 | 1: 51 | cmp r0,$2 52 | bne 1f 53 | 54 | / 2 = Unassigned 3K 55 | mov $3,-(r1) / rf0 dae = track number high bits 56 | mov $172000,-(r1) / rf0 dar = 256KW - 3KW 57 | clr -(r1) / rf0 cma = 0 58 | mov $-6000,-(r1) / rf0 wc = 3KW 59 | br loadrf 60 | 61 | 1: 62 | cmp r0,$10 63 | bne 1f 64 | 65 | / 10 = Dump 12K to DECtape drive 7 66 | mov $177350,r1 67 | clr -(r1) / tc11 tcba = 0 68 | mov $-30000,-(r1) / tc11 tcwc = 12KW 69 | mov $3415,-(r1) / tc11 tccm = UNIT=7,WDATA,DO 70 | tstb (r1) / tc11 done? 71 | bge .-2 / no, loop 72 | 2: 73 | halt 74 | br 2b 75 | 76 | 1: 77 | halt / Unrecognized switch setting 78 | br 1b 79 | -------------------------------------------------------------------------------- /fs/new/usr/boot/msys.s: -------------------------------------------------------------------------------- 1 | / msys -- copy file to RF read only slot 2 | / 3 | / re-creation, based on description in UNIX_ProgammersManual_Nov71.pdf, 4 | / page 7-06, BOOT PROCEDURES (VII) 5 | / 5/9/08 jam@magic.com 6 | 7 | / b bos 1700 8 | / u warm unix 1704 9 | / 1 cold unix 1734 10 | / 2 unassigned 1764 11 | 12 | mov sp,r5 13 | mov (r5)+,r3 / argc 14 | cmp $3,r3 / must be 3 15 | bne badcmd / else error 16 | tst (r5)+ 17 | mov (r5)+,r4 / get first arg 18 | 19 | cmpb (r4),$'b 20 | bne 1f 21 | mov $1700,r3 22 | br 2f 23 | 1: 24 | cmpb (r4),$'u 25 | bne 1f 26 | mov $1704,r3 27 | br 2f 28 | 1: 29 | cmpb (r4),$'1 30 | bne 1f 31 | mov $1734,r3 32 | br 2f 33 | 1: 34 | cmpb (r4),$'2 35 | bne badcmd 36 | mov $1764,r3 37 | 2: 38 | 39 | / open file 40 | mov (r5),r4 41 | mov r4,0f 42 | sys open; 0:..; 0 43 | bes error 44 | mov r0,r1 45 | 46 | / open rf0 and seek to correct block 47 | sys open; disk; 1 48 | bes error 49 | mov r0,r2 50 | mov r3,0f 51 | sys seek; 0:..; 0 52 | bes error 53 | 54 | / copy file from file to disk one block at a time 55 | 1: 56 | mov r1,r0 57 | sys read; buf; 512. 58 | mov r0,r4 59 | mov r2,r0 60 | sys write; buf; 512. 61 | bes error 62 | tst r4 63 | bne 1b 64 | 65 | sys exit 66 | 67 | error: 68 | mov $1,r0 69 | sys write; 1f; 2 70 | 4 71 | sys exit 72 | 1: 73 | 74 | 75 | badcmd: 76 | mov $1,r0 77 | sys write; 1f; 2 78 | 4 79 | sys exit 80 | 1: 81 | 82 | 83 | disk: 84 | 85 | .even 86 | 87 | buf: .=.+512. 88 | -------------------------------------------------------------------------------- /fs/new/usr/boot/run: -------------------------------------------------------------------------------- 1 | as bos.s 2 | mv a.out bos 3 | as msys.s 4 | mv a.out msys 5 | -------------------------------------------------------------------------------- /fs/new/usr/boot/wunix: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/new/usr/boot/wunix -------------------------------------------------------------------------------- /fs/root/bin/:: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/: -------------------------------------------------------------------------------- /fs/root/bin/ar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/ar -------------------------------------------------------------------------------- /fs/root/bin/as: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/as -------------------------------------------------------------------------------- /fs/root/bin/bas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/bas -------------------------------------------------------------------------------- /fs/root/bin/cal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/cal -------------------------------------------------------------------------------- /fs/root/bin/cat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/cat -------------------------------------------------------------------------------- /fs/root/bin/cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/cc -------------------------------------------------------------------------------- /fs/root/bin/chball: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/chball -------------------------------------------------------------------------------- /fs/root/bin/check: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/check -------------------------------------------------------------------------------- /fs/root/bin/chmod: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/chmod -------------------------------------------------------------------------------- /fs/root/bin/chown: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/chown -------------------------------------------------------------------------------- /fs/root/bin/cmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/cmp -------------------------------------------------------------------------------- /fs/root/bin/cp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/cp -------------------------------------------------------------------------------- /fs/root/bin/date: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/date -------------------------------------------------------------------------------- /fs/root/bin/db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/db -------------------------------------------------------------------------------- /fs/root/bin/dc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/dc -------------------------------------------------------------------------------- /fs/root/bin/df: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/df -------------------------------------------------------------------------------- /fs/root/bin/ds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/ds -------------------------------------------------------------------------------- /fs/root/bin/dsw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/dsw -------------------------------------------------------------------------------- /fs/root/bin/du: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/du -------------------------------------------------------------------------------- /fs/root/bin/echo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/echo -------------------------------------------------------------------------------- /fs/root/bin/ed: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/ed -------------------------------------------------------------------------------- /fs/root/bin/exit: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/exit -------------------------------------------------------------------------------- /fs/root/bin/fc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/fc -------------------------------------------------------------------------------- /fs/root/bin/find: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/find -------------------------------------------------------------------------------- /fs/root/bin/form: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/form -------------------------------------------------------------------------------- /fs/root/bin/goto: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/goto -------------------------------------------------------------------------------- /fs/root/bin/if: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/if -------------------------------------------------------------------------------- /fs/root/bin/ld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/ld -------------------------------------------------------------------------------- /fs/root/bin/ln: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/ln -------------------------------------------------------------------------------- /fs/root/bin/login: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/login -------------------------------------------------------------------------------- /fs/root/bin/ls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/ls -------------------------------------------------------------------------------- /fs/root/bin/mail: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/mail -------------------------------------------------------------------------------- /fs/root/bin/maki: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/maki -------------------------------------------------------------------------------- /fs/root/bin/mesg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/mesg -------------------------------------------------------------------------------- /fs/root/bin/mkdir: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/mkdir -------------------------------------------------------------------------------- /fs/root/bin/mv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/mv -------------------------------------------------------------------------------- /fs/root/bin/nm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/nm -------------------------------------------------------------------------------- /fs/root/bin/od: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/od -------------------------------------------------------------------------------- /fs/root/bin/pr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/pr -------------------------------------------------------------------------------- /fs/root/bin/rew: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/rew -------------------------------------------------------------------------------- /fs/root/bin/rm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/rm -------------------------------------------------------------------------------- /fs/root/bin/rmdir: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/rmdir -------------------------------------------------------------------------------- /fs/root/bin/roff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/roff -------------------------------------------------------------------------------- /fs/root/bin/sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/sh -------------------------------------------------------------------------------- /fs/root/bin/size: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/size -------------------------------------------------------------------------------- /fs/root/bin/skip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/skip -------------------------------------------------------------------------------- /fs/root/bin/sort: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/sort -------------------------------------------------------------------------------- /fs/root/bin/stat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/stat -------------------------------------------------------------------------------- /fs/root/bin/strip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/strip -------------------------------------------------------------------------------- /fs/root/bin/stty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/stty -------------------------------------------------------------------------------- /fs/root/bin/su: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/su -------------------------------------------------------------------------------- /fs/root/bin/sum: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/sum -------------------------------------------------------------------------------- /fs/root/bin/tap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/tap -------------------------------------------------------------------------------- /fs/root/bin/tm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/tm -------------------------------------------------------------------------------- /fs/root/bin/tty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/tty -------------------------------------------------------------------------------- /fs/root/bin/un: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/un -------------------------------------------------------------------------------- /fs/root/bin/wc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/wc -------------------------------------------------------------------------------- /fs/root/bin/who: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/who -------------------------------------------------------------------------------- /fs/root/bin/write: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/bin/write -------------------------------------------------------------------------------- /fs/root/etc/as2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/etc/as2 -------------------------------------------------------------------------------- /fs/root/etc/getty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/etc/getty -------------------------------------------------------------------------------- /fs/root/etc/glob: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/etc/glob -------------------------------------------------------------------------------- /fs/root/etc/init: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/etc/init -------------------------------------------------------------------------------- /fs/root/etc/msh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/etc/msh -------------------------------------------------------------------------------- /fs/root/etc/passwd: -------------------------------------------------------------------------------- 1 | root::0:/: 2 | eroot::0:/:/bin/ed 3 | sys::1:/usr/sys: 4 | bin::3:/bin: 5 | adm::3:/usr/adm: 6 | s1::3:/usr/s1: 7 | s2::3:/usr/s2: 8 | jack::10:/usr/jack: 9 | peter::11:/usr/peter: 10 | jay::12:/usr/jay: 11 | bob::13:/usr/bob: 12 | sun::14:/usr/sun: 13 | lee::15:/usr/lee: 14 | -------------------------------------------------------------------------------- /fs/root/etc/std0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/etc/std0 -------------------------------------------------------------------------------- /fs/root/etc/suftab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/etc/suftab -------------------------------------------------------------------------------- /fs/root/etc/uids: -------------------------------------------------------------------------------- 1 | root:0 2 | sys:1 3 | bin:3 4 | adm:3 5 | jack:10 6 | peter:11 7 | jay:12 8 | bob:13 9 | sun:14 10 | lee:15 11 | -------------------------------------------------------------------------------- /fs/root/tmp/etma: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/tmp/etma -------------------------------------------------------------------------------- /fs/root/tmp/ttmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/tmp/ttmp -------------------------------------------------------------------------------- /fs/root/tmp/utmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/tmp/utmp -------------------------------------------------------------------------------- /fs/root/usr/.placeholder: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/root/usr/.placeholder -------------------------------------------------------------------------------- /fs/usr/boot/bos.s: -------------------------------------------------------------------------------- 1 | / bos -- UNIX V1 bootstrap 2 | / 3 | / re-creation, based on description in UNIX_ProgammersManual_Nov71.pdf, 4 | / page 7-06, BOOT PROCEDURES (VII) 5 | / 5/6/08 jam@magic.com 6 | / 7 | / M792 bootstrap loads this into core at 54000 8 | / 9 | / Behavior depends on switch register: 10 | / 173700 or 11 | / 073700 Read Warm UNIX from RF into core location 0 and jump to 400 12 | / 1 Read Cold UNIX from RF into core location 0 and jump to 400 13 | / 2 Read unassigned 3K program into core location 0 and jump to 400 14 | / 10 Dump 12K words from core location 0 onto DECtape drive 7 15 | / 0 UNIMPLEMENTED -- should be read UNIX binary paper tape 16 | 17 | csw = 177570 18 | 19 | /. = 54000 20 | 21 | mov $177472,r1 22 | mov *$csw,r0 23 | cmp r0,$173700 24 | beq warm 25 | cmp r0,$73700 26 | bne 1f 27 | warm: 28 | / x73700 = Warm UNIX 29 | mov $3,-(r1) / rf0 dae = track number high bits 30 | mov $142000,-(r1) / rf0 dar = 256KW - 15KW 31 | clr -(r1) / rf0 cma = 0 32 | mov $-14000,-(r1) / rf0 wc = 6KW 33 | loadrf: 34 | mov $5,-(r1) / rf0 dcs = read 35 | tstb (r1) / rf0 done? 36 | bge .-2 / no, loop 37 | jmp *$400 / jump to loaded code 38 | 39 | 1: 40 | cmp r0,$1 41 | bne 1f 42 | 43 | / 0 = Cold UNIX 44 | mov $3,-(r1) / rf0 dae = track number high bits 45 | mov $156000,-(r1) / rf0 dar = 256KW - 9KW 46 | clr -(r1) / rf0 cma = 0 47 | mov $-14000,-(r1) / rf0 wc = 6KW 48 | br loadrf 49 | 50 | 1: 51 | cmp r0,$2 52 | bne 1f 53 | 54 | / 2 = Unassigned 3K 55 | mov $3,-(r1) / rf0 dae = track number high bits 56 | mov $172000,-(r1) / rf0 dar = 256KW - 3KW 57 | clr -(r1) / rf0 cma = 0 58 | mov $-6000,-(r1) / rf0 wc = 3KW 59 | br loadrf 60 | 61 | 1: 62 | cmp r0,$10 63 | bne 1f 64 | 65 | / 10 = Dump 12K to DECtape drive 7 66 | mov $177350,r1 67 | clr -(r1) / tc11 tcba = 0 68 | mov $-30000,-(r1) / tc11 tcwc = 12KW 69 | mov $3415,-(r1) / tc11 tccm = UNIT=7,WDATA,DO 70 | tstb (r1) / tc11 done? 71 | bge .-2 / no, loop 72 | 2: 73 | 0 / halt 74 | br 2b 75 | 76 | 1: 77 | 0 / halt -- unrecognized switch setting 78 | br 1b 79 | -------------------------------------------------------------------------------- /fs/usr/boot/msys.s: -------------------------------------------------------------------------------- 1 | / msys -- copy file to RF read only slot 2 | / 3 | / re-creation, based on description in UNIX_ProgammersManual_Nov71.pdf, 4 | / page 7-06, BOOT PROCEDURES (VII) 5 | / 5/9/08 jam@magic.com 6 | 7 | / b bos 1700 8 | / u warm unix 1704 9 | / 1 cold unix 1734 10 | / 2 unassigned 1764 11 | 12 | mov sp,r5 13 | mov (r5)+,r3 / argc 14 | cmp $3,r3 / must be 3 15 | bne badcmd / else error 16 | tst (r5)+ 17 | mov (r5)+,r4 / get first arg 18 | 19 | cmpb (r4),$'b 20 | bne 1f 21 | mov $1700,r3 22 | br 2f 23 | 1: 24 | cmpb (r4),$'u 25 | bne 1f 26 | mov $1704,r3 27 | br 2f 28 | 1: 29 | cmpb (r4),$'1 30 | bne 1f 31 | mov $1734,r3 32 | br 2f 33 | 1: 34 | cmpb (r4),$'2 35 | bne badcmd 36 | mov $1764,r3 37 | 2: 38 | 39 | / open file 40 | mov (r5),r4 41 | mov r4,0f 42 | sys open; 0:..; 0 43 | bes error 44 | mov r0,r1 45 | 46 | / open rf0 and seek to correct block 47 | sys open; disk; 1 48 | bes error 49 | mov r0,r2 50 | mov r3,0f 51 | sys seek; 0:..; 0 52 | bes error 53 | 54 | / copy file from file to disk one block at a time 55 | 1: 56 | mov r1,r0 57 | sys read; buf; 512. 58 | mov r0,r4 59 | mov r2,r0 60 | sys write; buf; 512. 61 | bes error 62 | tst r4 63 | bne 1b 64 | 65 | sys exit 66 | 67 | error: 68 | mov $1,r0 69 | sys write; 1f; 2 70 | 4 71 | sys exit 72 | 1: 73 | 74 | 75 | badcmd: 76 | mov $1,r0 77 | sys write; 1f; 2 78 | 4 79 | sys exit 80 | 1: 81 | 82 | 83 | disk: 84 | 85 | .even 86 | 87 | buf: .=.+512. 88 | -------------------------------------------------------------------------------- /fs/usr/boot/msys2.s: -------------------------------------------------------------------------------- 1 | / msys2 -- copy file to RF read only slot 2 | / 3 | / re-creation, based on description in UNIX_ProgammersManual_Nov71.pdf, 4 | / page 7-06, BOOT PROCEDURES (VII) 5 | / 5/9/08 jam@magic.com 6 | / 5/17/08 jam@magic.com -- modified to copy 407-format a.out files 7 | 8 | / b bos 1700 1KW 9 | / u warm unix 1704 6KW 10 | / 1 cold unix 1734 6KW 11 | / 2 unassigned 1764 3KW 12 | 13 | mov sp,r5 14 | mov (r5)+,r3 / argc 15 | cmp $3,r3 / must be 3 16 | bne badcmd / else error 17 | tst (r5)+ 18 | mov (r5)+,r4 / get first arg 19 | 20 | cmpb (r4),$'b 21 | bne 1f 22 | mov $1700,r3 23 | mov $4,r4 24 | br 2f 25 | 1: 26 | cmpb (r4),$'u 27 | bne 1f 28 | mov $1704,r3 29 | mov $30,r4 30 | br 2f 31 | 1: 32 | cmpb (r4),$'1 33 | bne 1f 34 | mov $1734,r3 35 | mov $30,r4 36 | br 2f 37 | 1: 38 | cmpb (r4),$'2 39 | bne badcmd 40 | mov $1764,r3 41 | mov $14,r4 42 | 2: 43 | 44 | / open file 45 | mov (r5),r5 46 | mov r5,0f 47 | sys open; 0:..; 0 48 | bes error 49 | mov r0,r1 50 | sys seek; 20; 0 / skip 407 (16-byte) header 51 | bes error 52 | 53 | / open rf0 and seek to correct block 54 | sys open; disk; 1 55 | bes error 56 | mov r0,r2 57 | mov r3,0f 58 | sys seek; 0:..; 0 59 | bes error 60 | 61 | / copy file from file to disk one block at a time 62 | 1: 63 | mov r1,r0 64 | sys read; buf; 512. 65 | mov r0,r5 66 | mov r2,r0 67 | sys write; buf; 512. 68 | bes error 69 | dec r4 70 | beq 3f 71 | tst r5 72 | bne 1b 73 | 74 | 3: 75 | sys exit 76 | 77 | error: 78 | mov $1,r0 79 | sys write; 1f; 2 80 | br .+2 81 | sys exit 82 | 1: 83 | 84 | 85 | badcmd: 86 | mov $1,r0 87 | sys write; 1f; 2 88 | br .+2 89 | sys exit 90 | 1: 91 | 92 | 93 | disk: 94 | 95 | .even 96 | 97 | buf: .=.+512. 98 | -------------------------------------------------------------------------------- /fs/usr/boot/run: -------------------------------------------------------------------------------- 1 | as bos.s 2 | mv a.out bos 3 | as msys2.s 4 | mv a.out msys2 5 | -------------------------------------------------------------------------------- /fs/usr/boot/unix.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/usr/boot/unix.out -------------------------------------------------------------------------------- /fs/usr/fort/fc1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/usr/fort/fc1 -------------------------------------------------------------------------------- /fs/usr/fort/fc2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/usr/fort/fc2 -------------------------------------------------------------------------------- /fs/usr/fort/fc3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/usr/fort/fc3 -------------------------------------------------------------------------------- /fs/usr/fort/fc4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/usr/fort/fc4 -------------------------------------------------------------------------------- /fs/usr/jack/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/usr/jack/a.out -------------------------------------------------------------------------------- /fs/usr/jack/x.f: -------------------------------------------------------------------------------- 1 | a = 2.3 2 | i = 10 3 | print 100, a, i 4 | 100 format(2hhi, f10.2, i5) 5 | end 6 | -------------------------------------------------------------------------------- /fs/usr/ken/maki.s: -------------------------------------------------------------------------------- 1 | / maki -- make initialization dec tape 2 | 3 | sys open; std0; 0 4 | bes error 5 | mov r0,r1 6 | sys read; buf; 512. 7 | mov r1,r0 8 | sys close 9 | sys open; tap0; 1 10 | bes error 11 | mov r0,r1 12 | sys write; buf; 512. 13 | bes error 14 | sys open; rf; 0 15 | bes error 16 | mov r0,r2 17 | jsr pc,copy 18 | mov r1,r0 19 | sys close 20 | sys open; tap1; 1 21 | bes error 22 | mov r0,r1 23 | jsr pc,copy 24 | sys exit 25 | 26 | copy: 27 | mov $512.,-(sp) 28 | 1: 29 | mov r2,r0 30 | sys read; buf; 512. 31 | bes error 32 | mov r1,r0 33 | sys write; buf; 512. 34 | bes error 35 | dec (sp) 36 | bne 1b 37 | tst (sp)+ 38 | rts pc 39 | 40 | error: 41 | mov $1,r0 42 | sys write; mes; emes-mes 43 | sys exit 44 | 45 | mes: 46 | 47 | emes: 48 | tap0: 49 | tap1: 50 | rf: 51 | std0: 52 | .even 53 | 54 | buf: .=.+512. 55 | -------------------------------------------------------------------------------- /fs/usr/lib/bilib.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/usr/lib/bilib.a -------------------------------------------------------------------------------- /fs/usr/lib/c0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/usr/lib/c0 -------------------------------------------------------------------------------- /fs/usr/lib/c1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/usr/lib/c1 -------------------------------------------------------------------------------- /fs/usr/lib/filib.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/usr/lib/filib.a -------------------------------------------------------------------------------- /fs/usr/lib/liba.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/usr/lib/liba.a -------------------------------------------------------------------------------- /fs/usr/lib/libb.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/usr/lib/libb.a -------------------------------------------------------------------------------- /fs/usr/lib/libc.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/usr/lib/libc.a -------------------------------------------------------------------------------- /fs/usr/lib/libf.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/usr/lib/libf.a -------------------------------------------------------------------------------- /fs/usr/sys/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/usr/sys/a.out -------------------------------------------------------------------------------- /fs/usr/sys/core: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jserv/unix-v1/725e723e8e8fde4f1f43301ef0331555ba2a2e8b/fs/usr/sys/core -------------------------------------------------------------------------------- /fs/usr/x: -------------------------------------------------------------------------------- 1 | tap x\ 2 | ./fort/fc1\ 3 | ./fort/fc2\ 4 | ./fort/fc3\ 5 | ./fort/fc4 6 | -------------------------------------------------------------------------------- /notes/TODO.txt: -------------------------------------------------------------------------------- 1 | - consider writing a mount.s? 2 | - can we get fpsym? What would its function be? 3 | - get dc-11 support into simh. started but lots to be done 4 | - bob supnik is doing this now. 5 | - roll up a set of images and place on site for download 6 | - roll up a tree snapshot and place on site for download 7 | - place patched simh up for download until official release is out 8 | - disassemble the s2 binaries into an assemblable form. 9 | - perform some comparisons with existing sources 10 | - try to track down people involved in jun72 kernel printout 11 | 12 | Done 13 | - 0407 binaries supported through a patch. 14 | - init and sh built from sources 15 | - bob supnik replaced our ke patches with his own official version 16 | - got Early_C_Compiler working with some kernel patches to support 17 | larger core size and 0407 binaries 18 | - we have reconstructed fragments from 1972_stuff 19 | 20 | -------------------------------------------------------------------------------- /notes/s2files.txt: -------------------------------------------------------------------------------- 1 | This is an invetory of the s2 files that are incorporated into the 2 | system as compared to what files should be on a proper first edition 3 | system. Some files are missing, some files are borrowed from 2nd ed 4 | but present as 0405 binaries, and some files are 2nd ed binaries that 5 | the 1st ed kernel cannot run. 6 | 7 | 8 | /bin 9 | ---- 10 | : V2 cmd, 0405 binary 11 | ar 12 | as V2 binary 13 | b missing 14 | bas 15 | bcd missing 16 | boot missing 17 | cal 18 | cat 19 | cc V2 binary 20 | chball ? no idea 21 | check 22 | chmod 23 | chown 24 | cmp 25 | cp 26 | date 27 | db 28 | dbppt missing 29 | dc 30 | df 31 | ds V2 binary 32 | dsw 33 | ds V2 binary 34 | dsw 35 | dtf missing 36 | du 37 | echo V2 cmd, 0405 binary 38 | ed 39 | exit V2 cmd, 0405 binary 40 | fc V2 binary 41 | find V2 binary 42 | form 43 | goto V2 cmd, 0405 binary 44 | hup missing 45 | if V2 cmd, 0405 binary 46 | lbppt missing 47 | ld V2 binary 48 | ln 49 | login V2 cmd, 0405 binary 50 | ls 51 | mail 52 | maki V2 binary 53 | mesg 54 | mkdir 55 | mkfs 56 | mount 57 | mv 58 | nm V2 binary 59 | od 60 | pr 61 | rew 62 | rkd missing 63 | rkf missing 64 | rkl missing 65 | rm 66 | rmdir 67 | roff 68 | rmdir 69 | roff 70 | sdate missing 71 | sh 72 | size V2 binary 73 | skip ? no idea 74 | sort 75 | stat 76 | strip V2 binary 77 | stty V2 cmd, 0405 binary 78 | su 79 | sum 80 | tap 81 | tm 82 | tty 83 | type 84 | un V2 binary 85 | wc 86 | who 87 | write 88 | 89 | /etc 90 | ---- 91 | as2 V2 binary 92 | getty V2 cmd, 0405 binary 93 | glob 94 | init 95 | msh 96 | suftab 97 | uids 98 | 99 | -------------------------------------------------------------------------------- /pages/e00-01: -------------------------------------------------------------------------------- 1 | / u0 -- unix 2 | 3 | cold = 0 4 | orig = 0 . / orig = 0. relocatable 5 | 6 | rkda = 177412 / disk address reg rk03/rk11 7 | rkds = 177400 / driv status reg rk03/rk11 8 | rkcs = 177404 / control status reg rk03/rk11 9 | rcsr = 174000 / receiver status reg dc-11 10 | rcbr = 174002 / receiver buffer reg dc-11 11 | tcsr = 174004 / xmtr status reg dc-11 12 | tcbr = 174006 / xmtr buffer reg dc-11 13 | tcst = 177340 / dec tape control status tc11/tu56 14 | tccm = 177342 / dec tape command reg tc11/tu56 15 | tcwc = 177344 / word count tc11/tu56 16 | tcba = 177346 / bus addr tc11/tu56 17 | tcdt = 177350 / data reg tc11/tu56 18 | dcs = 177460 / drum control status rf11/rs11 19 | dae = 177470 / drum address extension rf11/rs11 20 | lks = 177546 / clock status reg kw11-l 21 | prs = 177550 / papertape reader status pc11 22 | prb = 177552 / buffer pc11 23 | pps = 177554 / punch status pc11 24 | ppb = 177556 / punch buffer pc11 25 | /lps = 177514 line printer status (future) 26 | /lpb = 177516 line printer buffer (future) 27 | tks = 177560 / console read status asr-33 28 | tkb = 177562 / read buffer asr-33 29 | tps = 177564 / punch status asr-33 30 | tpb = 177566 / punch buffer asr-33 31 | ps = 177776 / processor status 32 | 33 | halt = 0 34 | wait = 1 35 | rti = 2 36 | 37 | nproc = 16. / number of processes 38 | nfiles = 50. 39 | ntty = 8+1 40 | nbuf = 6 41 | .if cold / ignored if cold = 0 42 | nbuf = 2 43 | .endif 44 | 45 | core = orig+40000 / specifies beginning of user's core 46 | ecore = core+20000 / specifies end of user's core (4096 words) 47 | 48 | / 4;4 init by copy 49 | / unkni;0 " error 50 | / fpsym;0 " illg in tr 51 | unkni;0 / trace and trap (see Sec. B.1 page ) 52 | unkni;0 / trap 53 | panic;0 / pwr 54 | rtssym;0 / emt 55 | sysent;0 / sys 56 | -------------------------------------------------------------------------------- /pages/e00-03: -------------------------------------------------------------------------------- 1 | mov $bufp,r1 2 | 1: 3 | mov r0,(r1)+ 4 | add $8,r0 5 | mov r0,-2(r0) / bus address 6 | mov $-256.,-4(r0) / word count 7 | add $512.,r0 / buffer space 8 | cmp r1,$bufp+nbuf+nbuf 9 | blo 1b 10 | mov $sb0,(r1)+ / I/O queue entry drum 11 | mov $sb1,(r1)+ / I/O queue entry disk (mounted device) 12 | mov $swp,(r1)+ / I/O queue entry core image being swapped 13 | mov $[systm-inode]\/2,sb0+4 / sets up initial buffers per 14 | / format given in 15 | mov $systm,sb0+6 / memory map 16 | mov $-512.,sb1+4 17 | mov $mount,sb1+6 18 | mov $user,swp+6 19 | 20 | / set devices to interrupt 21 | 22 | mov $100,*$lks / put 100 into clock status register; 23 | / enables clock interrupt 24 | 25 | / set up time out subroutines 26 | 27 | mov $touts,r0 28 | mov $startty,(r0)+ / if toutt = 0 call startty 29 | mov $pptito,(r0)+ / if toutt+1 = 0 call pptito 30 | tst (r0)+ / add 2 to r0 31 | mov $ntty-1,r1 32 | 1 : 33 | mov $xmtto,(r0)+ / if toutt+2 thru toutt+2+ntty=0 call xmtto 34 | dec r1 35 | bne 1b 36 | 37 | / free all character blocks; see H.0 for description 38 | 39 | mov $510.,r2 40 | mov $-1,r1 41 | 1: 42 | jsr r0,put 43 | sub $2,r2 44 | bgt 1b 45 | 46 | / set up drum swap addresses; see H.0 for description 47 | 48 | mov $1024.-64.,r1 / highest drum address; high 64 blks allocated 49 | / to UNIX 50 | mov $p.dska,r2 / p.dska contains dis addresses for processes 51 | 1 : 52 | sub $17.,r1 / 17 blocks per process 53 | mov r1,(r2)+ 54 | cmp r2,$p.dska+nproc+nproc 55 | bne 1b 56 | 57 | -------------------------------------------------------------------------------- /pages/e00-06: -------------------------------------------------------------------------------- 1 | rtssym: 2 | mov r0,-(sp) 3 | mov r1,-(sp) 4 | mov 4(sp),r0 5 | mov -(r0),r0 6 | bic $!7,r0 7 | asl r0 8 | jmp *1f(r0) 9 | 1: 10 | 0f;1f;2f;3f;4f;5f;badrts;7f 11 | 0: 12 | mov 2(sp),r0 13 | br 1f 14 | 2: 15 | mov r2,r1 16 | br 1f 17 | 3: 18 | mov r3,r1 19 | br 1f 20 | 4: 21 | mov r4,r1 22 | br 1f 23 | 5: 24 | mov r5,r1 25 | br 1f 26 | 7: 27 | mov 8.(sp),r1 28 | 1: 29 | cmp r1,$core 30 | blo badrts 31 | cmp r1,$ecore 32 | bhis badrts 33 | bit $1,r1 34 | bne badrts 35 | tst (r1) 36 | beq badrts 37 | add $1f,r0 38 | mov r0,4(sp) 39 | mov (sp)+,r1 40 | mov (sp)+,r0 41 | rti 42 | 1: 43 | rts r0 44 | rts r1 45 | rts r2 46 | rts r3 47 | rts r4 48 | rts r5 49 | rts sp 50 | rts pc 51 | 52 | badrts: 53 | mov (sp)+,r1 54 | mov (sp)+,r0 55 | rpsym: 56 | -------------------------------------------------------------------------------- /pages/e00-07: -------------------------------------------------------------------------------- 1 | jmp unkni 2 | 3 | .if cold 4 | 5 | idata: 6 | 7 | / root 8 | 9 | 41. 10 | 140016 11 | .byte 7,1 12 | 9f-.-2 13 | 41. 14 | <..\0\0\0\0\0\0> 15 | 41. 16 | <.\0\0\0\0\0\0\0> 17 | 42. 18 | 19 | 43. 20 | 21 | 44. 22 | 23 | 45. 24 | 25 | 46. 26 | 27 | 9: 28 | 29 | / device directory 30 | 31 | 42. 32 | 140016 33 | .byte 2,1 34 | 9f-.-2 35 | 41. 36 | <..\0\0\0\0\0\0> 37 | 42. 38 | <.\0\0\0\0\0\0\0> 39 | 01. 40 | 41 | 02. 42 | 43 | 03. 44 | 45 | 04. 46 | 47 | 05. 48 | 49 | 06. 50 | 51 | 07. 52 | 53 | 08. 54 | 55 | 09. 56 | 57 | -------------------------------------------------------------------------------- /pages/e00-08: -------------------------------------------------------------------------------- 1 | 10. 2 | 3 | 11. 4 | 5 | 12. 6 | 7 | 13. 8 | 9 | 14. 10 | 11 | 15. 12 | 13 | 16. 14 | 15 | 17. 16 | 17 | 18. 18 | 19 | 19. 20 | 21 | 20. 22 | 23 | 21. 24 | 25 | 22. 26 | 27 | 01. 28 | / really tty 29 | 9: 30 | 31 | / binary directory 32 | 33 | 43. 34 | 140016 35 | .byte 2,3 36 | 9f-.-2 37 | 41. 38 | <..\0\0\0\0\0\0> 39 | 43. 40 | <.\0\0\0\0\0\0\0> 41 | 9: 42 | 43 | / etcetra directory 44 | 45 | 44. 46 | 140016 47 | .byte 2,3 48 | 9f-.-2 49 | 41. 50 | <..\0\0\0\0\0\0> 51 | 44. 52 | <.\0\0\0\0\0\0\0> 53 | 47. 54 | 55 | 9: 56 | 57 | -------------------------------------------------------------------------------- /pages/e00-09: -------------------------------------------------------------------------------- 1 | / user directory 2 | 3 | 45. 4 | 140016 5 | .byte 2,1 6 | 9f-.-2 7 | 41. 8 | <..\0\0\0\0\0\0> 9 | 45. 10 | <.\0\0\0\0\0\0\0> 11 | 9: 12 | 13 | / temporary directory 14 | 15 | 46. 16 | 140017 17 | .byte 2,1 18 | 9f-.-2 19 | 41. 20 | <..\0\0\0\0\0\0> 21 | 46. 22 | <.\0\0\0\0\0\0\0> 23 | 9: 24 | 25 | / initialization program 26 | 27 | 47. 28 | 100036 29 | .byte 1,3 30 | 9f-.-2 31 | 8: 32 | sys break; 0 33 | sys open; 6f-8b+core; 0 34 | mov r0,r1 35 | sys seek; 65.; 0 36 | 1: 37 | mov r1,r0 38 | sys read; 9f-8b+core; 512. 39 | mov 9f,r5 / size 40 | beq 1f 41 | sys creat; 9f-8b+core+4; 0 42 | mov r0,r2 43 | movb 9f+2,0f 44 | sys chmod; 9f-8b+core+4; 0:.. 45 | movb 9f+3,0f 46 | sys chown; 9f-8b+core+4; 0:.. 47 | 2: 48 | tst r5 49 | beq 2f 50 | mov r1,r0 51 | sys read; 9f-8b+core; 512. 52 | mov $512.,0f 53 | cmp r5,$512. 54 | bhi 3f 55 | mov r5,0f 56 | 3: 57 | -------------------------------------------------------------------------------- /pages/e00-10: -------------------------------------------------------------------------------- 1 | mov r2,r0 2 | sys write; 9f-8b+core; 0:.. 3 | sub r0,r5 4 | br 2b 5 | 2: 6 | mov r2,r0 7 | sys close 8 | br 1b 9 | 1: 10 | mov r1,r0 11 | sys close 12 | sys exec; 5f-8b+core; 4f-8b+core 13 | sys exit 14 | 4: 15 | 5f-8b+core; 0 16 | 5: 17 | 18 | 6: 19 | 20 | .even 21 | 9: 22 | 23 | / end of initialization data 24 | 25 | 0 26 | 27 | .endif 28 | 29 | -------------------------------------------------------------------------------- /pages/e01-01: -------------------------------------------------------------------------------- 1 | / u1 -- unix 2 | 3 | unkni: / used for all system calls 4 | sysent: 5 | incb sysflg / indicate a system routine is 6 | beq 1f / in progress 7 | jmp panic / called if trap inside system 8 | 1: 9 | mov $s.syst+2,clockp 10 | mov r0,-(sp) / save user registers 11 | mov sp,u.r0 / pointer to bottom of users stack in u.r0 12 | mov r1,-(sp) 13 | mov r2,-(sp) 14 | mov r3,-(sp) 15 | mov r4,-(sp) 16 | mov r5,-(sp) 17 | mov ac,-(sp) / "accumulator" register for extended 18 | / arithmetic unit 19 | mov mq,-(sp) / "multiplier quotient" register for the 20 | / extended arithmetic unit 21 | mov sc,-(sp) / "step count" register for the extended 22 | / arithmetic unit 23 | mov sp,u.sp / u.sp points to top of users stack 24 | mov 18.(sp),r0 / store pc in r0 25 | mov -(r0),r0 / sys inst in r0 10400xxx 26 | sub $sys,r0 / get xxx code 27 | asl r0 / multiply by 2 to jump indirect in bytes 28 | cmp r0,$2f-1f / limit of table (35) exceeded 29 | bhis badsys / yes, bad system call 30 | bic $341,20.(sp) / set users processor priority to 0 and clear 31 | / carry bit 32 | jmp *1f(r0) / jump indirect thru table of addresses 33 | / to proper system routine. 34 | 1: 35 | sysrele / 0 36 | sysexit / 1 37 | sysfork / 2 38 | sysread / 3 39 | syswrite / 4 40 | sysopen / 5 41 | sysclose / 6 42 | syswait / 7 43 | syscreat / 8 44 | syslink / 9 45 | sysunlink / 10 46 | sysexec / 11 47 | syschdir / 12 48 | systime / 13 49 | sysmkdir / 14 50 | syschmod / 15 51 | syschown / 16 52 | sysbreak / 17 53 | sysstat / 18 54 | sysseek / 19 55 | systell / 20 56 | -------------------------------------------------------------------------------- /pages/e01-02: -------------------------------------------------------------------------------- 1 | sysmount / 21 2 | sysumount / 22 3 | syssetuid / 23 4 | sysgetuid / 24 5 | sysstime / 25 6 | sysquit / 26 7 | sysintr / 27 8 | sysfstat / 28 9 | sysemt / 29 10 | sysmdate / 30 11 | sysstty / 31 12 | sysgtty / 32 13 | sysilgins / 33 14 | 2: 15 | 16 | error: 17 | mov u.sp,r1 18 | bis $1,20.(r1) / set c bit in processor status word below 19 | / users stack 20 | 21 | sysret: 22 | tstb u.bsys / is a process about to be terminated because 23 | bne sysexit / of an error? yes, go to sysexit 24 | mov u.sp,sp / no point stack to users stack 25 | clr r1 / zero r1 to check last mentioned i-node 26 | jsr r0,iget / if last mentioned i-node has been modified 27 | / it is written out 28 | tstb smod / has the super block been modified 29 | beq 1f / no, 1f 30 | clrb smod / yes, clear smod 31 | bis $1000,sb0 / set write bit in I/O queue for super block 32 | / output 33 | jsr r0,ppoke / write out modified super block to disk 34 | 1: 35 | tstb mmod / has the super block for the dismountable file 36 | / system 37 | beq 1f / been modified? no, 1f 38 | clrb mmod / yes, clear mmod 39 | movb mntd,sb1 / set the I/O queue 40 | bis $1000,sb1 / set write bit in I/O queue for detached sb 41 | jsr r0,ppoke / write it out to its device 42 | 1: 43 | tstb uquant / is the time quantum 0? 44 | bne 1f / no, don't swap it out 45 | 46 | sysrele: 47 | jsr r0,tswap / yes, swap it out 48 | 1: 49 | mov (sp)+,sc / restore user registers 50 | mov (sp)+,mq 51 | mov (sp)+,ac 52 | mov (sp)+,r5 53 | mov (sp)+,r4 54 | mov (sp)+,r3 55 | mov (sp)+,r2 56 | mov (sp)+,r1 57 | -------------------------------------------------------------------------------- /pages/e01-10: -------------------------------------------------------------------------------- 1 | beq 1f / if 0 1f 2 | mov r3,tcsr(r1) / move p.c. status to printer control status reg 3 | 1: 4 | mov (r2)+,tty+4(r1) / move to flag byte of tty block 5 | jmp sysret2 / return to user 6 | 7 | sysgtty: / get status of typewriter; 3 consequtive word arguments 8 | jsr r0,gtty / r1 will have offset to tty block, r2 has 9 | / destination 10 | mov rcsr(r1),(r2)+ / put reader control status in 1st word 11 | / of dest 12 | mov tcsr(r1),(r2)+ / put printer control status in 2nd word 13 | / of dest 14 | mov tty+4(r1),(r2)+ / put mode in 3rd word 15 | jmp sysret2 / return to user 16 | 17 | gtty: 18 | jsr r0,arg; u.off / put first arg in u.off 19 | mov *u.r0,r1 / put file descriptor in r1 20 | jsr r0,getf / get the i-number of the file 21 | tst r1 / is it open for reading 22 | bgt 1f / yes 23 | neg r1 / no, i-number is negative, so make it positive 24 | 1: 25 | sub $14.,r1 / get i-number of tty0 26 | cmp r1,$ntty-1 / is there such a typewriter 27 | bhis error9 / no, error 28 | asl r1 / 0%2 29 | asl r1 / 0%4 / yes 30 | asl r1 / 0%8 / multiply by 8 so r1 points to tty block 31 | mov u.off,r2 / put argument in r2 32 | rts r0 / return 33 | -------------------------------------------------------------------------------- /pages/e02-02: -------------------------------------------------------------------------------- 1 | mov (sp)+,r1 / get i-number back 2 | jsr r0,iget / get i-node 3 | jsr r0,setimod / set modified flag 4 | decb i.nlks / decrement the number of links 5 | bgt sysret9 / if this was not the last link to file return 6 | jsr r0,anyi / if it was, see if anyone has it open. Then 7 | / free contents of file and destroy it. 8 | br sysret9 9 | 10 | mkdir: 11 | jsr r0,copyz; u.dirbuf+2; u.dirbuf+10. / clear this 12 | mov u.namep,r2 / r2 points to name of directory entry 13 | mov $u.dirbuf+2,r3 / r3 points to u.dirbuf+2 14 | 1: / put characters in the directory name in u.dirbuf+2 - u.dirbuf+10 15 | movb (r2)+,r1 / move character in name to r1 16 | beq 1f / if null, done 17 | cmp r1,$'/ / is it a "/"? 18 | beq error9 / yes, error 19 | cmp r3,$u.dirbuf+10. / have we reached the last slot for 20 | / a char? 21 | beq 1b / yes, go back 22 | movb r1,(r3)+ / no, put the char in the u.dirbuf 23 | br 1b / get next char 24 | 1: 25 | mov u.dirp,u.off / pointer to empty current directory slot to 26 | /u.off 27 | 28 | wdir: 29 | mov $u.dirbuf,u.base / u.base points to created file name 30 | mov $10.,u.count / u.count = 10 31 | mov ii,r1 / r1 has i-number of current directory 32 | jsr r0,access; 1 / get i-node and set its file up for writing 33 | jsr r0,writei / write into directory 34 | rts r0 35 | 36 | sysexec: 37 | jsr r0,arg2 / arg0 in u.namep,arg1 on top of stack 38 | jsr r0,namei / namei returns i-number of file named in 39 | / sysexec call in r1 40 | br error9 41 | jsr r0,iget / get i-node for file to be executed 42 | bit $20,i.flgs / is file executable 43 | beq error9 44 | jsr r0,iopen / gets i-node for file with i-number given in 45 | / r1 (opens file) 46 | bit $40,i.flgs / test user id on execution bit 47 | beq 1f 48 | tstb u.uid / test user id 49 | beq 1f / super user 50 | movb i.uid,u.uid / put user id of owner of file as process 51 | / user id 52 | 1: 53 | mov (sp)+,r5 / r5 now contains address of list of pointers to 54 | / arguments to be passed 55 | mov $1,u.quit / u.quit determines handling of quits; 56 | / u.quit = 1 take quit 57 | -------------------------------------------------------------------------------- /pages/e02-04: -------------------------------------------------------------------------------- 1 | clr u.break 2 | mov r5,sp / point sp to user's stack 3 | mov $14,u.count 4 | mov $u.off,u.fofp 5 | clr u.off / set offset in file to be read to zero 6 | jsr r0,readi / read in first six words of user's file, starting 7 | / at $core 8 | mov sp,r5 / put users stack address in r5 9 | sub $core+40.,r5 / subtract $core +40, from r5 (leaves 10 | / number of words less 26 available for 11 | / program in user core 12 | mov r5,u.count / 13 | cmp core,$405 / br .+14 is first instruction if file is 14 | / standard a.out format 15 | bne 1f / branch, if not standard format 16 | mov core+2,r5 / put 2nd word of users program in r5; number of 17 | / bytes in program text 18 | sub $14,r5 / subtract 12 19 | cmp r5,u.count / 20 | bgt 1f / branch if r5 greater than u.count 21 | mov r5,u.count 22 | jsr r0,readi / read in rest of user's program text 23 | add core+10,u.nread / add size of user data area to u.nread 24 | br 2f 25 | 1: 26 | jsr r0,readi / read in rest of file 27 | 2: 28 | mov u.nread,u.break / set users program break to end of 29 | / user code 30 | add $core+14,u.break / plus data area 31 | jsr r0,iclose / does nothing 32 | br sysret3 / return to core image at $core 33 | 34 | sysfstat: / set status of open file 35 | jsr r0,arg; u.off / put buffer address in u.off 36 | mov u.off,-(sp) / put buffer address on the stack 37 | mov *u.r0,r1 / put file descriptor in r1 38 | jsr r0,getf / get the files i-number 39 | tst r1 / is it 0? 40 | beq error3 / yes, error 41 | bgt 1f / if i-number is negative (open for writing) 42 | neg r1 / make it positive, then branch 43 | br 1f / to 1f 44 | 45 | sysstat: / ; name of file; buffer - get files status 46 | jsr r0,arg2 / get the 2 arguments 47 | jsr r0,namei / get the i-number for the file 48 | br error3 / no such file, error 49 | 1: 50 | jsr r0,iget / get the i-node into core 51 | mov (sp)+,r3 / move u.off to r3 (points to buffer) 52 | mov r1,(r3)+ / put i-number in 1st word of buffer 53 | mov $inode,r2 / r2 points to i-node 54 | 1: 55 | mov (r2)+,(r3)+ / move rest of i-node to buffer 56 | cmp r2,$inode+32 / done? 57 | -------------------------------------------------------------------------------- /pages/e02-05: -------------------------------------------------------------------------------- 1 | bne 1b / no, go back 2 | br sysret3 / return through sysret 3 | 4 | error3: 5 | jmp error / see 'error' routine 6 | sysret3: 7 | jmp sysret / see 'sysret' routine 8 | 9 | getf: / get the device number and the i-number of an open file 10 | cmp r1,$10. / user limited to 10 open files 11 | bhis error3 / u.fp is table of users open files, index in 12 | / fsp table 13 | movb u.fp(r1),r1 / r1 contains number of entry in fsp table 14 | beq 1f / if its zero return 15 | asl r1 16 | asl r1 / multiply by 8 to get index into fsp table entry 17 | asl r1 18 | add $fsp-4,r1 / r1 is pointing at the 3rd word in the fsp entry 19 | mov r1,u.fofp / save address of 3rd word in fsp entry in u.fofp 20 | mov -(r1),cdev / remove the device number cdev 21 | mov -(r1),r1 / and the i-number r1 22 | 1: 23 | rts r0 24 | 25 | namei: 26 | mov u.cdir,r1 / put the i-number of current directory in r1 27 | mov u.cdev,cdev / device number for users directory into cdev 28 | cmpb *u.namep,$'/ / is first char in file name a / 29 | bne 1f 30 | inc u.namep / go to next char 31 | mov rootdir,r1 / put i-number of rootdirectory in r1 32 | clr cdev / clear device number 33 | 1: 34 | tstb *u.namep / is the character in file name a nul 35 | beq nig / yes, end of file name reached; branch to "nig" 36 | 1: 37 | jsr r0,access; 2 / get i-node with i-number r1 38 | bit $40000,i.flgs / directory i-node? 39 | beq error3 / no, got an error 40 | mov i.size,u.dirp / put size of directory in u.dirp 41 | clr u.off / u.off is file offset used by user 42 | mov $u.off,u.fofp / u.fofp is a pointer to the offset portion 43 | / of fsp entry 44 | 2: 45 | mov $u.dirbuf,u.base / u.dirbuf holds a file name copied from 46 | / a directory 47 | mov $10.,u.count / u.count is byte count for reads and writes 48 | jsr r0,readi / read 10. bytes of file with i-number (r1); 49 | / i.e. read a directory entry 50 | tst u.nread 51 | ble nib / gives error return 52 | tst u.dirbuf / 53 | bne 3f / branch when active directory entry (i-node word in 54 | / entry non zero) 55 | mov u.off,u.dirp 56 | sub $10.,u.dirp 57 | -------------------------------------------------------------------------------- /pages/e02-06: -------------------------------------------------------------------------------- 1 | br 2b 2 | 3: 3 | mov u.namep,r2 / u.namep points into a file name string 4 | mov $u.dirbuf+2,r3 / points to file name of directory entry 5 | 3: 6 | movb (r2)+,r4 / move a character from u.namep string into r4 7 | beq 3f / if char is nul, then the last char in string has been 8 | / moved 9 | cmp r4,$'/ / is char a 10 | beq 3f 11 | cmp r3,$u.dirbuf+10. / have I checked all 8 bytes of file name 12 | beq 3b 13 | cmpb (r3)+,r4 / compare char in u.namep string to file name 14 | / char read from 15 | beq 3b / directory; branch if chars match 16 | br 2b / file names do not match go to next directory entry 17 | 3: 18 | cmp r3,$u.dirbuf+10. / if equal all 8 bytes were matched 19 | beq 3f 20 | tstb (r3)+ / 21 | bne 2b 22 | 3: 23 | mov r2,u.namep / u.namep points to char following a / or nul 24 | mov u.dirbuf,r1 / move i-node number in directory entry to r1 25 | tst r4 / if r4 = 0 the end of file name reached, if r4 = 26 | / then go to next directory 27 | bne 1b 28 | 29 | nig: 30 | tst (r0)+ / gives non-error return 31 | nib: 32 | rts r0 33 | 34 | syschdir: / makes the directory specified in the argument the current 35 | / directory 36 | jsr r0,arg; u.namep / u.namep points to path name 37 | jsr r0,namei / find its i-number 38 | br error3 39 | jsr r0,access; 2 / get i-node into core 40 | bit $40000,i.flgs / is it a directory? 41 | beq error3 / no error 42 | mov r1,u.cdir / move i-number to users current directory 43 | mov cdev,u.cdev / move its device to users current device 44 | br sysret3 45 | 46 | isown: 47 | jsr r0,arg2 / u.namep points to file name 48 | jsr r0,namei / get its i-number 49 | br error3 50 | jsr r0,iget / get i-node into core 51 | tstb u.uid / super user? 52 | beq 1f / yes, branch 53 | cmpb i.uid,u.uid / no, is this the owner of the file 54 | beq 1f / yes 55 | jmp error3 / no, error 56 | 1: 57 | -------------------------------------------------------------------------------- /pages/e02-07: -------------------------------------------------------------------------------- 1 | jsr r0,setimod / indicates i-node has been modified 2 | mov (sp)+,r2 / mode is put in r2 (u.off put on stack with 3 | / 2nd arg) 4 | rts r0 5 | 6 | syschmod: / name; mode 7 | jsr r0,isown / get the i-node and check user status 8 | bit $40000,i.flgs / directory? 9 | beq 2f / no 10 | bic $60,r2 / su & ex / yes, clear set user id and 11 | / executable modes 12 | 2: 13 | movb r2,i.flgs / move remaining mode to i.flgs 14 | br 1f 15 | 16 | syschown: / name; owner 17 | jsr r0,isown / get the i-node and check user status 18 | tstb u.uid / super user 19 | beq 2f / yes, 2f 20 | bit $40,i.flgs / no, set userid on execution? 21 | bne 3f / yes error, could create Trojan Horses 22 | 2: 23 | movb r2,i.uid / no, put the new owners id in the i-node 24 | 1: 25 | jmp sysret4 26 | 3: 27 | jmp error 28 | 29 | arg: 30 | mov u.sp,r1 31 | mov *18.(r1),*(r0)+ / put argument of system call into 32 | / argument of arg2 33 | add $2,18.(r1) / point pc on stack to next system argument 34 | rts r0 35 | 36 | arg2: 37 | jsr r0,arg; u.namep / u.namep contains value of first arg in 38 | / sys call 39 | jsr r0,arg; u.off / u.off contains value of second arg in 40 | / sys call 41 | mov r0,r1 / r0 points to calling routine 42 | mov (sp),r0 / put operation code back in r0 43 | mov u.off,(sp) / put pointer to second argument on stack 44 | jmp (r1) / return to calling routine 45 | 46 | systime: / get time of year 47 | mov s.time,4(sp) 48 | mov s.time+2,2(sp) / put the present time on the stack 49 | br sysret4 50 | 51 | sysstime: / set time 52 | tstb u.uid / is user the super user 53 | bne error4 / no, error 54 | mov 4(sp),s.time 55 | mov 2(sp),s.time+2 / set the system time 56 | br sysret4 57 | 58 | -------------------------------------------------------------------------------- /pages/e02-09: -------------------------------------------------------------------------------- 1 | br sysret4 2 | 3 | systell: / get the r/w pointer 4 | jsr r0,seektell 5 | br error4 6 | 7 | error4: 8 | jmp error / see 'error' routine 9 | sysret4: 10 | jmp sysret / see 'sysret' routine 11 | 12 | seektell: 13 | jsr r0,arg; u.base / puts offset in u.base 14 | jsr r0,arg; u.count / put ptr name in u.count 15 | mov *u.r0,r1 / file descriptor in r1 (index in u.fp list) 16 | jsr r0,getf / u.fofp points to 3rd word in fsp entry 17 | mov r1,-(sp) / r1 has i-number of file, put it on the stack 18 | beq error4 / if i-number is 0, not active so error 19 | bgt .+4 / if its positive jump 20 | neg r1 / if not make it positive 21 | jsr r0,iget / get its i-node into core 22 | cmp u.count,$1 / is ptr name =1 23 | blt 2f / no its zero 24 | beq 1f / yes its 1 25 | mov i.size,u.count / put number of bytes in file in u.count 26 | br 2f 27 | 1: / ptr name =1 28 | mov *u.fofp,u.count / put offset in u.count 29 | 2: / ptrname =0 30 | mov (sp)+,r1 / i-number on stack r1 31 | rts r0 32 | 33 | sysintr: / set interrupt handling 34 | jsr r0,arg; u.intr / put the argument in u.intr 35 | br 1f / go into quit routine 36 | sysquit: 37 | jsr r0,arg; u.quit / put argument in u.quit 38 | 1: 39 | mov u.ttyp,r1 / move pointer to control tty buffer to r1 40 | beq sysret4 / return to user 41 | clrb 6(r1) / clear the interrupt character in the tty buffer 42 | br sysret4 / return to user 43 | 44 | syssetuid: / set process id 45 | movb *u.r0,r1 / move process id (number) to r1 46 | cmpb r1,u.ruid / is it equal to the real user id number 47 | beq 1f / yes 48 | tstb u.uid / no, is current user the super user? 49 | bne error4 / no, error 50 | 1: 51 | movb r1,u.uid / put process id in u.uid 52 | movb r1,u.ruid / put process id in u.ruid 53 | br sysret4 / system return 54 | 55 | sysgetuid: 56 | movb u.ruid,*u.r0 / move the real user id to (u.r0) 57 | br sysret4 / systerm return, sysret 58 | -------------------------------------------------------------------------------- /pages/e02-10: -------------------------------------------------------------------------------- 1 | 2 | fclose: 3 | mov r1,-(sp) / put r1 on the stack (it contains the index 4 | / to u.fp list) 5 | jsr r0,getf / r1 contains i-number, cdev has device =, u.fofp 6 | / points to 3rd word of fsp entry 7 | tst r1 / is inumber 0? 8 | beq 1f / yes, i-node not active so return 9 | tst (r0)+ / no, jump over error return 10 | mov r1,r2 / move i-number to r2 11 | mov (sp),r1 / restore value of r1 from the stack which is 12 | / index to u.fp 13 | clrb u.fp(r1) / clear that entry in the u.fp list 14 | mov u.fofp,r1 / r1 points to 3rd word in fsp entry 15 | decb 2(r1) / decrement the number of processes that have opened 16 | / the file 17 | bge 1f / if all processes haven't closed the file, return 18 | mov r2,-(sp) / put r2 on the stack (i-number) 19 | clr -4(r1) / clear 1st word of fsp entry 20 | tstb 3(r1) / has this file been deleted 21 | beq 2f / no, branch 22 | mov r2,r1 / yes, put i-number back into r1 23 | jsr r0,anyi / free all blocks related to i-number 24 | / check if file appears in fsp again 25 | 2: 26 | mov (sp)+,r1 / put i-number back into r1 27 | jsr r0,iclose / check to see if its a special file 28 | 1: 29 | mov (sp)+,r1 / put index to u.fp back into r1 30 | rts r0 31 | 32 | anyi: / r1 contains an i-number 33 | mov $fsp,r2 / move start of fsp table to r2 34 | 1: 35 | cmp r1,(r2) / do i-numbers match? 36 | beq 1f / yes, 1f 37 | neg r1 / no complement r1 38 | cmp r1,(r2) / do they match now? 39 | beq 1f / yes, transfer 40 | / i-numbers do not match 41 | add $8,r2 / no, bump to next entry in fsp table 42 | cmp r2,$fsp+[nfiles*8] / are we at last entry in the table 43 | blt 1b / no, check next entries i-number 44 | tst r1 / yes, no match 45 | bge .+4 46 | neg r1 / make i-number positive 47 | jsr r0,imap / get address of allocation bit in the i-map in r2 48 | bicb mq,(r2) / clear bit for i-node in the imap 49 | jsr r0,itrunc / free all blocks related to i-node 50 | clr i.flgs / clear all flags in the i-node 51 | rts r0 / return 52 | 1: / i-numbers match 53 | incb 7(r2) / increment upper byte of the 4th word 54 | rts r0 / in that fsp entry (deleted flag of fsp entry) 55 | -------------------------------------------------------------------------------- /pages/e03-03: -------------------------------------------------------------------------------- 1 | 2 | cmp r2,$core / at beginning of user program yet? 3 | blos 2f / yes, return 4 | cmp r2,u.usp / is break_above the "stack pointer before 5 | / swapping" 6 | bhis 2f / yes, return 7 | mov $ecore,r3 / r3 points to end of core 8 | add r3,r2 9 | sub u.usp,r2 / end of users stack is in r2 10 | 1: 11 | mov -(r2),-(r3) / move stack back to its normal place 12 | cmp r2,u.break / in core 13 | bne 1b 14 | 2: 15 | rts r0 16 | 17 | putlu: / r1 = user process no.; r2 points to lowest priority queue 18 | tstb (r2)+ / is queue empty? 19 | beq 1f / yes, branch 20 | movb (r2),r3 / no, save the "last user" process number in r3 21 | movb r1,p.link-1(r3) / put pointer to user on "last users" link 22 | br 2f / 23 | 1: 24 | movb r1,-1(r2) / user is only user; put process no. at beginning 25 | / and at end 26 | 2: 27 | movb r1,(r2) / user process in r1 is now the last entry on 28 | / the queue 29 | dec r2 / restore r2 30 | rts r0 31 | 32 | copyz: 33 | mov r1,-(sp) / put r1 on stack 34 | mov r2,-(sp) / put r2 on stack 35 | mov (r0)+,r1 36 | mov (r0)+,r2 37 | 1: 38 | clr (r1)+ / clear all locations between r1 and r2 39 | cmp r1,r2 40 | blo 1b 41 | mov (sp)+,r2 / restore r2 42 | mov (sp)+,r1 / restore r1 43 | rts r0 44 | 45 | idle: 46 | mov *$ps,-(sp) / save ps on stack 47 | clr *$ps / clear ps 48 | mov clockp,-(sp) / save clockp on stack 49 | mov (r0)+,clockp / arg to idle in clockp 50 | 1 / wait for interrupt 51 | mov (sp)+,clockp / restore clockp, ps 52 | mov (sp)+,*$ps 53 | rts r0 54 | 55 | clear: 56 | jsr r0,wslot / get an I/O buffer set bits 9 and 15 in first 57 | / word of I/O queue r5 points to first data word 58 | 59 | 60 | -------------------------------------------------------------------------------- /pages/e03-04: -------------------------------------------------------------------------------- 1 | / in buffer 2 | mov $256.,r3 3 | 1: 4 | clr (r5)+ / zero data word in buffer 5 | dec r3 6 | bgt 1b / branch until all data words in buffer are zero 7 | jsr r0,dskwr / write zeroed buffer area out onto physical 8 | / block specified 9 | rts r0 / in r1 10 | 11 | 12 | -------------------------------------------------------------------------------- /pages/e04-01: -------------------------------------------------------------------------------- 1 | / u4 -- unix 2 | 3 | setisp: 4 | mov r1,-(sp) 5 | mov r2,-(sp) 6 | mov r3,-(sp) 7 | mov clockp,-(sp) 8 | mov $s.syst+2,clockp 9 | jmp (r0) 10 | 11 | clock: / interrupt from 60 cycle clock 12 | mov r0,-(sp) / save r0 13 | tst *$lks / restart clock? 14 | mov $s.time+2,r0 / increment the time of day 15 | inc (r0) 16 | bne 1f 17 | inc -(r0) 18 | 1: 19 | mov clockp,r0 / increment appropriate time category 20 | inc (r0) 21 | bne 1f 22 | inc -(r0) 23 | 1: 24 | mov $uquant,r0 / decrement user time quantum 25 | decb (r0) 26 | bge 1f / if less than 0 27 | clrb (r0) / make it 0 28 | 1: / decrement time out counts return now if priority was not 0 29 | cmp 4(sp),$200 / ps greater than or equal to 200 30 | bge 2f / yes, check time outs 31 | tstb (r0) / no, user timed out? 32 | bne 1f / no 33 | cmpb sysflg,$-1 / yes, are we outside the system? 34 | bne 1f / no, 1f 35 | mov (sp)+,r0 / yes, put users r0 in r0 36 | sys 0 / sysrele 37 | rti 38 | 2: / priority is high so just decrement time out counts 39 | mov $toutt,r0 / r0 points to beginning of time out table 40 | 2: 41 | tstb (r0) / is the time out? 42 | beq 3f / yes, 3f (get next entry) 43 | decb (r0) / no, decrement the time 44 | bne 3f / isit zero now? 45 | incb (r0) / yes, increment the time 46 | 3: 47 | inc r0 / next entry 48 | cmp r0,$touts / end of toutt table? 49 | blo 2b / no, check this entry 50 | mov (sp)+,r0 / yes, restore r0 51 | rti / return from interrupt 52 | 1: / decrement time out counts; if 0 call subroutine 53 | mov (sp)+,r0 / restore r0 54 | mov $240,*$ps / set processor priority to 5 55 | jsr r0,setisp / save registers 56 | -------------------------------------------------------------------------------- /pages/e04-04: -------------------------------------------------------------------------------- 1 | / jsr r0,setisp 2 | / jsr r0,starlpt 3 | / br retisp 4 | ppto: / paper tape output interrupt routine 5 | jsr r0,setisp / save registers 6 | jsr r0,starppt / get next character from clist, and output 7 | / if possible 8 | br retisp / pop register values from stack 9 | 10 | / starlpt: 11 | / cmpb cc+5.,$100. 12 | / bhi 1f 13 | / jsr r0,wakeup; runq+2; 5 14 | /1: 15 | / tstb *$lps 16 | / bge 1f 17 | / jsr r0,getc; 5 18 | / br 1f 19 | / mov r1,*$lpb 20 | / br starlpt 21 | /1: 22 | / rts r0 23 | 24 | startty: / start or restart console tty output 25 | cmpb cc+1,$5. 26 | bhi 1f / branch to 1f when character count on tty (? input, 27 | / output) list is greater than 5. 28 | jsr r0,wakeup; runq+2; 1 29 | 1: 30 | tstb *$tps / test console output ready bit 31 | bge 2f / branch if ready bit is clear 32 | tstb toutt+0 / is toutt for console a zero 33 | bne 2f / if not; branch to 2f 34 | movb ttyoch,r1 / put character to be output in r1 35 | bne 1f 36 | jsr r0,getc; 1 / if char is nul, get a char from console 37 | / output list 38 | br 2f / if console output list is empty, branch to 2f 39 | 1: 40 | clrb ttyoch 41 | mov r1,*$tpb / put character in console output register 42 | cmp r1,$12 / is char a line feed 43 | bne 1f 44 | movb $15,ttyoch / put a cr in ttyoch 45 | 1: 46 | cmp r1,$11 / char = ht 47 | bne 1f 48 | movb $15.,toutt+0 / set time out to 15 clock tics 49 | 1: 50 | cmp r1,$15 / char = cr 51 | bne 2f 52 | movb $15.,toutt+0 / set time out to 15 clock ticks 53 | 2: 54 | rts r0 55 | -------------------------------------------------------------------------------- /pages/e04-07: -------------------------------------------------------------------------------- 1 | / key 2 | br 1b 3 | -------------------------------------------------------------------------------- /pages/e05-01: -------------------------------------------------------------------------------- 1 | / u5 -- unix 2 | 3 | mget: 4 | mov *u.fofp,mq / file offset in mq 5 | clr ac / later to be high sig 6 | mov $-8,lsh / divide ac/mq by 256. 7 | mov mq,r2 8 | bit $10000,i.flgs / lg/sm is this a large or small file 9 | bne 4f / branch for large file 10 | bit $!17,r2 11 | bne 3f / branch if r2 greater than or equal to 16 12 | bic $!16,r2 / clear all bits but bits 1,2,3 13 | mov i.dskp(r2),r1 / r1 has physical block number 14 | bne 2f / if physical block num is zero then need a new block 15 | / for file 16 | jsr r0,alloc / allocate a new block 17 | mov r1,i.dskp(r2) / physical block number stored in i-node 18 | jsr r0,setimod / set inode modified byte (imod) 19 | jsr r0,clear / zero out disk/drum block just allocated 20 | 2: 21 | rts r0 22 | 3: / adding on block which changes small file to a large file 23 | jsr r0,alloc / allocate a new block for this file; block number 24 | /in r1 25 | jsr r0,wslot / set up I/O buffer for write, r5 points to first 26 | / data word in buffer 27 | mov $8.,r3 / next 6 instructions transfer old physical block 28 | / pointers 29 | mov $i.dskp,r2 / into new indirect block for the new large file 30 | 1: 31 | mov (r2),(r5)+ 32 | clr (r2)+ 33 | dec r3 34 | bgt 1b 35 | mov $256.-8.,r3 / clear rest of data buffer 36 | 1: 37 | clr (r5)+ 38 | dec r3 39 | bgt 1b 40 | jsr r0,dskwr / write new indirect block on disk 41 | mov r1,i.dskp / put pointer to indirect block in i-node 42 | bis $10000,i.flgs / set large file bit in i.flgs word of i-node 43 | jsr r0,setimod / set i-node modified flag 44 | br mget 45 | 4: / large file 46 | mov $-8,lsh / divide byte number by 256. 47 | bic $!776,r2 / zero all bits but 1,2,3,4,5,6,7,8; gives offset 48 | / in indirect block 49 | mov r2,-(sp) / save on stack 50 | mov mq,r2 / calculate offset in i-node for pointer to proper 51 | / indirect block 52 | bic $!16,r2 53 | mov i.dskp(r2),r1 54 | bne 2f / if no indirect block exists 55 | jsr r0,alloc / allocate a new block 56 | -------------------------------------------------------------------------------- /pages/e05-02: -------------------------------------------------------------------------------- 1 | mov r1,i.dskp(r2) / put block number of new block in i-node 2 | jsr r0,setimod / set i-node modified byte 3 | jsr r0,clear / clear new block 4 | 2: 5 | jsr r0,dskrd / read in indirect block 6 | mov (sp)+,r2 / get offset 7 | mov r1,-(sp) / save block number of indirect block on stack 8 | add r5,r2 / r5 points to first word in indirect block, r2 9 | / points to location of inter 10 | mov (r2),r1 / put physical block no of block in file 11 | / sought in r1 12 | bne 2f / if no block exists 13 | jsr r0,alloc / allocate a new block 14 | mov r1,(r2) / put new block number into proper location in 15 | / indirect block 16 | mov (sp)+,r1 / get block number of indirect block 17 | mov (r2),-(sp) / save block number of new block 18 | jsr r0,wslot 19 | jsr r0,dskwr / write newly modified indirect block back out 20 | / on disk 21 | mov (sp),r1 / restore block number of new block 22 | jsr r0,clear / clear new block 23 | 2: 24 | tst (sp)+ / bump stack pointer 25 | rts r0 26 | 27 | alloc: 28 | mov r2,-(sp) / save r2, r3 on stack 29 | mov r3,-(sp) 30 | mov $systm,r2 / start of inode and free storage map for drum 31 | tst cdev 32 | beq 1f / drum is device 33 | mov $mount,r2 / disk or tape is device, start of inode and free 34 | / storage map 35 | 1: 36 | mov (r2)+,r1 / first word contains number of bytes in free 37 | / storage map 38 | asl r1 / multiply r1 by eight gives, number of blocks in device 39 | asl r1 40 | asl r1 41 | mov r1,-(sp) / save # of blocks in device on stack 42 | clr r1 / r1 contains bit count of free storage map 43 | 1: 44 | mov (r2)+,r3 / word of free storage map in r3 45 | bne 1f / branch if any free blocks in this word 46 | add $16.,r1 47 | cmp r1 ,(sp) / have we examined all free storage bytes 48 | blo 1b 49 | jmp panic / found no free storage 50 | 1: 51 | asr r3 / find a free block 52 | bcs 1f / branch when free block found; bit for block k is in 53 | / byte k/8 / in bit k (mod 8) 54 | inc r1 / increment bit count in bit k (mod8) 55 | br 1b 56 | 1: 57 | -------------------------------------------------------------------------------- /pages/e05-03: -------------------------------------------------------------------------------- 1 | tst (sp)+ / bump sp 2 | jsr r0,3f / have found a free block 3 | bic r3,(r2) / set bit for this block i.e. assign block 4 | br 2f 5 | 6 | free: 7 | mov r2,-(sp) / save r2, r3 8 | mov r3,-(sp) 9 | jsr r0,3f / set up bit mask and word no. in free storage map 10 | / for block 11 | bis r3,(r2) / set free storage block bit; indicates free block 12 | 2: 13 | mov (sp)+,r3 / restore r2, r3 14 | mov (sp)+,r2 15 | tst cdev / cdev = 0, block structured, drum; cdev = 1 16 | / mountable device 17 | bne 1f 18 | incb smod / set super block modified for drum 19 | rts r0 20 | 1: 21 | incb mmod / set super block modified for mountable device 22 | rts r0 23 | 3: 24 | mov r1,r2 / block number, k, = 1 25 | bic $!7,r2 / clear all bits but 0,1,2; r2 = (k) mod (8) 26 | clr r3 27 | bisb 2f(r2),r3 / use mask to set bit in r3 corresponding to 28 | / (k) mod 8 29 | mov r1,r2 / divide block number by 16 30 | asr r2 31 | asr r2 32 | asr r2 33 | asr r2 34 | bcc 1f / branch if bit 3 in r1 was 0 i.e., bit for block is in 35 | / lower half of word 36 | swab r3 / swap bytes in r3; bit in upper half of word in free 37 | / storage map 38 | 1: 39 | asl r2 / multiply block number by 2; r2 = k/8 40 | add $systm+2,r2 / address of word of free storage map for drum 41 | / with block bit in it 42 | tst cdev 43 | beq 1f / cdev = 0 indicates device is drum 44 | add $mount-systm,r2 / address of word of free storage map for 45 | / mountable device with bit of block to be 46 | / freed 47 | 1: 48 | rts r0 / return to 'free' 49 | 2: 50 | .byte 1,2,4,10,20,40,100,200 / masks for bits 0,...,7 51 | 52 | access: 53 | jsr r0,iget / read in i-node for current directory (i-number 54 | / passed in r1) 55 | mov i.flgs,r2 56 | -------------------------------------------------------------------------------- /pages/e05-04: -------------------------------------------------------------------------------- 1 | cmpb i.uid,u.uid / is user same as owner of file 2 | bne 1f / no, then branch 3 | asrb r2 / shift owner read write bits into non owner 4 | / read/write bits 5 | asrb r2 6 | 1: 7 | bit r2,(r0)+ / test read-write flags against argument in 8 | / access call 9 | bne 1f 10 | tstb u.uid 11 | beq 1f 12 | jmp error 13 | 1: 14 | rts r0 15 | 16 | setimod: 17 | movb $1,imod / set current i-node modified bytes 18 | mov s.time,i.mtim / put present time into file modified time 19 | mov s.time+2,i.mtim+2 20 | rts r0 21 | 22 | imap: / get the byte that has the allocation bit for the i-number contained 23 | / in r1 24 | mov $1,mq / put 1 in the mq 25 | mov r1,r2 / r2 now has i-number whose byte in the map we 26 | / must find 27 | sub $41.,r2 / r2 has i-41 28 | mov r2,r3 / r3 has i-41 29 | bic $!7,r3 / r3 has (i-41) mod 8 to get the bit position 30 | mov r3,lsh / move the 1 over (i-41) mod 8 positions to the left 31 | / to mask the correct bit 32 | asr r2 33 | asr r2 34 | asr r2 / r2 has (i-41) base 8 of the byte no. from the start of 35 | / the map 36 | mov r2,-(sp) / put (i-41) base 8 on the stack 37 | mov $systm,r2 / r2 points to the in-core image of the super 38 | / block for drum 39 | tst cdev / is the device the disk 40 | beq 1f / yes 41 | add $mount-systm,r2 / for mounted device, r2 points to 1st word 42 | / of its super block 43 | 1: 44 | add (r2)+,(sp) / get byte address of allocation bit 45 | add (sp)+,r2 / ? 46 | add $2,r2 / ? 47 | rts r0 48 | 49 | iget: 50 | cmp r1,ii / r1 = i-number of current flle 51 | bne 1f 52 | cmp idev,cdev / is device number of i-node = current device 53 | beq 2f 54 | 1: 55 | tstb imod / has i-node of current file been modified i.e., 56 | / imod set 57 | -------------------------------------------------------------------------------- /pages/e05-05: -------------------------------------------------------------------------------- 1 | beq 1f 2 | clrb imod / if it has, we must write the new i-node out on disk 3 | mov r1,-(sp) 4 | mov cdev,-(sp) 5 | mov ii,r1 6 | mov idev,cdev 7 | jsr r0,icalc; 1 8 | mov (sp)+,cdev 9 | mov (sp)+,r1 10 | 1: 11 | tst r1 / is new i-number non zero 12 | beq 2f / branch if r1=0 13 | tst cdev / is the current device number non zero (i.e., device 14 | / =/ drum) 15 | bne 1f / branch 1f cdev =/ 0 16 | cmp r1,mnti / mnti is the i-number of the cross devlce 17 | / file (root directory of mounted devlce) 18 | bne 1f 19 | mov mntd,cdev / make mounted device the current device 20 | mov rootdir,r1 21 | 1: 22 | mov r1,ii 23 | mov cdev,idev 24 | jsr r0,icalc; 0 / read in i-node ii 25 | 2: 26 | mov ii,r1 27 | rts r0 28 | 29 | icalc: / i-node i is located in block (i+31.)/16. and begins 32.* 30 | / (i+31)mod16 bytes from its start 31 | add $31.,r1 / add 31. to i-number 32 | mov r1,-(sp) / save i+31. on stack 33 | asr r1 / divide by 16. 34 | asr r1 35 | asr r1 36 | asr r1 / r1 contains block number of block in which 37 | / i-node exists 38 | jsr r0,dskrd / read in block containing i-node i. 39 | tst (r0) 40 | beq 1f / branch to wslot when argument in icalc call = 1 41 | jsr r0,wslot / set up data buffer for write (will be same buffer 42 | / as dskrd got) 43 | 1: 44 | bic $!17,(sp) / zero all but last 4 bits; gives (i+31.) mod 16 45 | mov (sp)+,mq / calculate offset in data buffer; 32.*(i+31.)mod16 46 | mov $5,lsh / for i-node i. 47 | add mq,r5 / r5 points to first word in i-node i. 48 | mov $inode,r1 / inode is address of first word of current i-node 49 | mov $16.,r3 50 | tst (r0)+ / branch to 2 fwhen argument in icalc call = 0 51 | beq 2f / r0 now contains proper return address for rts r0 52 | 1: 53 | mov (r1)+,(r5)+ / over write old i-node 54 | dec r3 55 | bgt 1b 56 | jsr r0,dskwr / write inode out on device 57 | -------------------------------------------------------------------------------- /pages/e05-06: -------------------------------------------------------------------------------- 1 | rts r0 2 | 2: 3 | mov (r5)+,(r1)+ / read new i-node into "inode" area of core 4 | dec r3 5 | bgt 2b 6 | rts r0 7 | 8 | itrunc: 9 | jsr r0,iget 10 | mov $i.dskp,r2 / address of block pointers in r2 11 | 1: 12 | mov (r2)+,r1 / move physical block number into r1 13 | beq 5f 14 | mov r2,-(sp) 15 | bit $10000,i.flgs / test large file bit? 16 | beq 4f / if clear, branch 17 | mov r1,-(sp) / save block number of indirect block 18 | jsr r0,dskrd / read in block, 1st data word pointed to by r5 19 | mov $256.,r3 / move word count into r3 20 | 2: 21 | mov (r5)+,r1 / put 1st data word in r1; physical block number 22 | beq 3f / branch if zero 23 | mov r3,-(sp) / save r3, r5 on stack 24 | mov r5,-(sp) 25 | jsr r0,free / free block in free storage map 26 | mov (sp)+,r5 27 | mov (sp)+,r3 28 | 3: 29 | dec r3 / decrement word count 30 | bgt 2b / branch if positive 31 | mov (sp)+,r1 / put physical block number of indirect block 32 | 4: 33 | jsr r0,free / free indirect block 34 | mov (sp)+,r2 35 | 5: 36 | cmp r2,$i.dskp+16. 37 | bne 1b / branch until all i.dskp entries check 38 | bic $10000,i.flgs / clear large file bit 39 | clr i.size / zero file size 40 | jsr r0,copyz; i.dskp; i.dskp+16. / zero block pointers 41 | jsr r0,setimod / set i-node modified flag 42 | mov ii,r1 43 | rts r0 44 | 45 | 46 | -------------------------------------------------------------------------------- /pages/e06-01: -------------------------------------------------------------------------------- 1 | / u6 -- unix 2 | 3 | readi: 4 | clr u.nread / accumulates number of bytes transmitted 5 | tst u.count / is number of bytes to be read greater than 0 6 | bgt 1f / yes, branch 7 | rts r0 / no, nothing to read; return to caller 8 | 1: 9 | mov r1,-(sp) / save i-number on stack 10 | cmp r1,$40. / want to read a special file (i-nodes 1,...,40 are 11 | / for special files) 12 | ble 1f / yes, branch 13 | jmp dskr / no, jmp to dskr; read file with i-node number (r1) 14 | / starting at byte ((u.fofp)), read in u.count bytes 15 | 1: 16 | asl r1 / multiply inode number by 2 17 | jmp *1f-2(r1) 18 | 1: 19 | rtty / tty; r1=2 20 | rppt / ppt; r1=4 21 | rmem / mem; r1=6 22 | rrf0 / rf0 23 | rrk0 / rk0 24 | rtap / tap0 25 | rtap / tap1 26 | rtap / tap2 27 | rtap / tap3 28 | rtap / tap4 29 | rtap / tap5 30 | rtap / tap6 31 | rtap / tap7 32 | rcvt / tty0 33 | rcvt / tty1 34 | rcvt / tty2 35 | rcvt / tty3 36 | rcvt / tty4 37 | rcvt / tty5 38 | rcvt / tty6 39 | rcvt / tty7 40 | rcrd/ crd 41 | 42 | rtty: / read from console tty 43 | mov tty+[8*ntty]-8+6,r5 / r5 is the address of the 4th word of 44 | / of the control and status block 45 | tst 2(r5) / for the console tty; this word points to the console 46 | / tty buffer 47 | bne 1f / 2nd word of console tty buffer contains number 48 | / of chars. Is this number non-zero? 49 | jsr r0,canon; ttych / if 0, call 'canon' to get a line 50 | / (120 chars.) 51 | 1: 52 | tst 2(r5) / is the number of characters zero 53 | beq ret1 / yes, return to caller via 'ret1' 54 | movb *4(r5),r1 / no, put character in r1 55 | inc 4(r5) / 3rd word of console tty buffer points to byte which 56 | / contains the next char. 57 | -------------------------------------------------------------------------------- /pages/e06-02: -------------------------------------------------------------------------------- 1 | dec 2(r5) / decrement the character count 2 | jsr r0,passc / move the character to core (user) 3 | br 1b / get next character 4 | 5 | ret1: 6 | jmp ret / return to caller via 'ret' 7 | 8 | rppt: / read paper tape 9 | jsr r0,pptic / gets next character in clist for ppt input and 10 | / places 11 | br ret / it in r1; if there 1s no problem with reader, it 12 | / also enables read bit in prs 13 | jsr r0,passc / place character in users buffer area 14 | br rppt 15 | 16 | rmem: / transfer characters from memory to a user area of core 17 | mov *u.fofp,r1 / save file offset which points to the char to 18 | / be transferred to user 19 | inc *u.fofp / increment file offset to point to 'next' char in 20 | / memory file 21 | movb (r1),r1 / get character from memory file, put it in r1 22 | jsr r0,passc / move this character to the next byte of the 23 | / users core area 24 | br rmem / continue 25 | 1: 26 | rcrd: 27 | jmp error / see 'error' routine 28 | 29 | dskr: 30 | mov (sp),r1 / i-number in r1 31 | jsr r0,iget / get i-node (r1) into i-node section of core 32 | mov i.size,r2 / file size in bytes in r2 33 | sub *u.fofp,r2 / subtract file offset 34 | blos ret 35 | cmp r2,u.count / are enough bytes left in file to carry out read 36 | bhis 1f 37 | mov r2,u.count / no, just read to end of file 38 | 1 : 39 | jsr r0,mget / returns physical block number of block in file 40 | / where offset points 41 | jsr r0,dskrd / read in block, r5 points to 1st word of data in 42 | / buffer 43 | jsr r0,sioreg 44 | 2: 45 | movb (r2)+,(r1)+ / move data from buffer into working core 46 | / starting at u.base 47 | dec r3 48 | bne 2b / branch until proper number of bytes are transferred 49 | tst u.count / all bytes read off disk 50 | bne dskr 51 | br ret 52 | 53 | passc: 54 | movb r1,*u.base / move a character to the next byte of the 55 | / users buffer 56 | inc u.base / increment the pointer to point to the next byte 57 | -------------------------------------------------------------------------------- /pages/e06-03: -------------------------------------------------------------------------------- 1 | / in users buffer 2 | inc u.nread / increment the number of bytes read 3 | dec u.count / decrement the number of bytes to be read 4 | bne 1f / any more bytes to read?; yes, branch 5 | mov (sp)+,r0 / no, do a non-local return to the caller of 6 | / 'readi' by: 7 | ret: / (1) pop the return address off the stack into r0 8 | mov (sp)+,r1 / (2) pop the i-number off the stack into r1 9 | 1: 10 | clr *$ps / clear processor status 11 | rts r0 / return to address currently on top of stack 12 | 13 | writei: 14 | clr u.nread / clear the number of bytes transmitted during 15 | / read or write calls 16 | tst u.count / test the byte count specified by the user 17 | bgt 1f / any bytes to output; yes, branch 18 | rts r0 / no, return - no writing to do 19 | 1: 20 | mov r1 ,-(sp) / save the i-node number on the stack 21 | cmp r1,$40. / does the i-node number indicate a special file? 22 | bgt dskw / no, branch to standard file output 23 | asl r1 / yes, calculate the index into the special file 24 | jmp *1f-2(r1) / jump table and jump to the appropriate routine 25 | 1: 26 | wtty / tty 27 | wppt / ppt 28 | wmem / mem 29 | wrf0 / rf0 30 | wrk0 / rk0 31 | wtap / tap0 32 | wtap / tap1 33 | wtap / tap2 34 | wtap / tap3 35 | wtap / tap4 36 | wtap / tap5 37 | wtap / tap6 38 | wtap / tap7 39 | xmtt / tty0 40 | xmtt / tty1 41 | xmtt / tty2 42 | xmtt / tty3 43 | xmtt / tty4 44 | xmtt / tty5 45 | xmtt / tty6 46 | xmtt / tty7 47 | / w1pr / lpr 48 | 49 | wtty: 50 | jsr r0,cpass / get next character from user buffer area; if 51 | / none go to return address in syswrite 52 | tst r1 / is character = null 53 | beq wtty / yes, get next character 54 | 1 : 55 | mov $240,*$ps / no, set processor priority to five 56 | -------------------------------------------------------------------------------- /pages/e06-04: -------------------------------------------------------------------------------- 1 | cmpb cc+1,$20. / is character count for console tty greater 2 | / than 20 3 | bhis 2f / yes; branch to put process to sleep 4 | jsr r0,putc; 1 / find place in freelist to assign to console 5 | / tty and 6 | br 2f / place character in list; if none available 7 | / branch to put process to sleep 8 | jsr r0,startty / attempt to output character on tty 9 | br wtty 10 | 2: 11 | mov r1,-(sp) / place character on stack 12 | jsr r0,sleep; 1 / put process to sleep 13 | mov (sp)+,r1 / remove character from stack 14 | br 1b / try again to place character in clist and output 15 | 16 | wppt: 17 | jsr r0,cpass / get next character from user buffer area, 18 | / if none return to writei's calling routine 19 | jsr r0,pptoc / output character on ppt 20 | br wppt 21 | /wlpr: 22 | / jsr r0,cpass 23 | / cmp r0,$'a 24 | / blo 1f 25 | / cmp r1,$'z 26 | / bhi 1f 27 | / sub $40,r1 28 | /1: 29 | / jsr r0,lptoc 30 | / br wlpr 31 | 32 | wmem: / transfer characters from a user area of core to memory file 33 | jsr r0,cpass / get next character from users area of core and 34 | / put it in r1 35 | mov r1,-(sp) / put character on the stack 36 | mov *u.fofp,r1 / save file offset in r1 37 | inc *u.fofp / increment file offset to point to next available 38 | / location in file 39 | movb (sp)+,(r1) / pop char off stack, put in memory loc assigned 40 | / to it 41 | br wmem / continue 42 | 1: 43 | jmp error / ? 44 | 45 | dskw: / write routine for non-special files 46 | mov (sp),r1 / get an i-node number from the stack into r1 47 | jsr r0,iget / write i-node out (if modified), read i-node 'r1' 48 | / into i-node area of core 49 | mov *u.fofp,r2 / put the file offset [(u.off) or the offset in 50 | / the fsp entry for this file] in r2 51 | add u.count,r2 / no. of bytes to be written + file offset is 52 | / put in r2 53 | cmp r2,i.size / is this greater than the present size of 54 | / the file? 55 | blos 1f / no, branch 56 | -------------------------------------------------------------------------------- /pages/e06-06: -------------------------------------------------------------------------------- 1 | mov u.base,r1 / address of data is in r1 2 | neg r3 / 512 - file offset (mod512.) in r3 (i.e., the number 3 | / of free bytes in the file block 4 | cmp r3,u.count / compare this with the number of data bytes to 5 | / be written to the file 6 | blos 2f / if less than branch. Use the number of free bytes 7 | / in the file block as the number to be written 8 | mov u.count,r3 / if greater than, use the number of data bytes 9 | / as the number to be written 10 | 2: 11 | add r3,u.nread / r3 + number of bytes xmitted during write is 12 | / put into u.nread 13 | sub r3,u.count / u.count = no. of bytes that still must be 14 | / written or read 15 | add r3,u.base / u.base points to the 1st of the remaining data 16 | / bytes 17 | add r3,*u.fofp / new file offset = number of bytes done + old 18 | / file offset 19 | rts r0 20 | 21 | -------------------------------------------------------------------------------- /pages/e07-04: -------------------------------------------------------------------------------- 1 | put: 2 | asr r2 / divide r2 by 2; r2 is offset in clist 3 | mov r2,-(sp) / save r2 on stack 4 | movb cl+1(r1),r2 / move offset of last char in list (r1) into r2 5 | beq 1f / offset = 0 then go to 1f (i.e., start a new list) 6 | bic $!377,r2 / zero top half of r2 7 | asl r2 / multiply offset by 2, r2 now has offset in clist 8 | movb (sp),clist-1(r2) / link new list entry to current last 9 | / entry in list (r1) 10 | br 2f 11 | 1: 12 | movb (sp),cf+1(r1) / put new list entry offset into first char 13 | / offset of list (r1) 14 | 2: 15 | mov (sp)+,r2 / pop stack into r2; offset of new list 16 | / entry in r2 17 | movb r2,cl+1(r1) / make new list entry the last entry in list 18 | / (r1) 19 | asl r2 / multiply r2 by 2; r2 has clist offset for new 20 | / list entry 21 | rts r0 22 | 23 | iopen: / open file whose i-number is in r1 24 | tst r1 / write or read access? 25 | blt 2f / write, go to 2f 26 | jsr r0,access; 2 / get inode into core with read access 27 | cmp r1,$40. / is it a special file 28 | bgt 3f / no. 3f 29 | mov r1,-(sp) / yes, figure out 30 | asl r1 31 | jmp *1f-2(r1) / which one and transfer to it 32 | 1: 33 | otty / tty 34 | oppt / ppt 35 | sret / mem 36 | sret / rf0 37 | sret / rk0 38 | sret / tap0 39 | sret / tap1 40 | sret / tap2 41 | sret / tap3 42 | sret / tap4 43 | sret / tap5 44 | sret / tap6 45 | sret / tap7 46 | ocvt / tty0 47 | ocvt / tty1 48 | ocvt / tty2 49 | ocvt / tty3 50 | ocvt / tty4 51 | ocvt / tty5 52 | ocvt / tty6 53 | ocvt / tty7 54 | error / crd 55 | 56 | -------------------------------------------------------------------------------- /pages/e07-05: -------------------------------------------------------------------------------- 1 | 2: / check open write access 2 | neg r1 / make inode number positive 3 | jsr r0,access; 1 / get inode in 0 core 4 | bit $40000,i.flgs / is it a directory? 5 | bne 2f / yes, transfer (error) 6 | cmp r1,$40. / no, is it a special file? 7 | bgt 3f / no, return 8 | mov r1,-(sp) / yes 9 | asl r1 10 | jmp *1f-2(r1) / figure out which special file it is 11 | / and transfer 12 | 1: 13 | otty / tty 14 | leadr / ppt 15 | sret / mem 16 | sret / rf0 17 | sret / rk0 18 | sret / tap0 19 | sret / tap1 20 | sret / tap2 21 | sret / tap3 22 | sret / tap4 23 | sret / tap5 24 | sret / tap6 25 | sret / tap7 26 | ocvt / tty0 27 | ocvt / tty1 28 | ocvt / tty2 29 | ocvt / tty3 30 | ocvt / tty4 31 | ocvt / tty5 32 | ocvt / tty6 33 | ocvt / tty7 34 | / ejec / lpr 35 | 36 | otty: / open console tty for reading or writing 37 | mov $100,*$tks / set interrupt enable bit (zero others) in 38 | / reader status reg 39 | mov $100,*$tps / set interrupt enable bit (zero others) in 40 | / punch status reg 41 | mov tty+[ntty*8]-8+6,r5 / r5 points to the header of the 42 | / console tty buffer 43 | incb (r5) / increment the count of processes that opened the 44 | / console tty 45 | tst u.ttyp / is there a process control tty (i.e., has a tty 46 | / buffer header 47 | bne sret / address been loaded into u.ttyp yet)? yes, branch 48 | mov r5,u.ttyp / no, make the console tty the process control 49 | / tty 50 | br sret / ? 51 | 52 | sret: 53 | clr *$ps / set processor priority to zero 54 | mov (sp)+,r1 / pop stack to r1 55 | 3: 56 | rts r0 57 | 58 | -------------------------------------------------------------------------------- /pages/e07-06: -------------------------------------------------------------------------------- 1 | oppt: / open paper tape for reading or writing 2 | mov $100,*$prs / set reader interrupt enable bit 3 | tstb pptiflg / is file already open 4 | bne 2f / yes, branch 5 | 1: 6 | mov $240,*$ps / no, set processor priority to 5 7 | jsr r0,getc; 2 / remove all entries in clist 8 | br .+4 / for paper tape input and place in free list 9 | br 1b 10 | movb $2,pptiflg / set pptiflg to indicate file just open 11 | movb $10.,toutt+1 / place 10 in paper tape input tout entry 12 | br sret 13 | 2: 14 | jmp error / file already open 15 | 16 | iclose: / close file whose i-number is in r1 17 | tst r1 / test i-number 18 | blt 2f / if neg., branch 19 | cmp r1,$40. / is it a special file 20 | bgt 3b / no, return 21 | mov r1,-(sp) / yes, save r1 on stack 22 | asl r1 23 | jmp *1f-2(r1) / compute jump address and transfer 24 | 1: 25 | ctty / tty 26 | cppt / ppt 27 | sret / mem 28 | sret / rf0 29 | sret / rk0 30 | sret / tap0 31 | sret / tap1 32 | sret / tap2 33 | sret / tap3 34 | sret / tap4 35 | sret / tap5 36 | sret / tap6 37 | sret / tap7 38 | ccvt / tty0 39 | ccvt / tty1 40 | ccvt / tty2 41 | ccvt / tty3 42 | ccvt / tty4 43 | ccvt / tty5 44 | ccvt / tty6 45 | ccvt / tty7 46 | error / crd 47 | 48 | 2: / negative i-number 49 | neg r1 / make it positive 50 | cmp r1,$40. / is it a special file 51 | bgt 3b / no. return 52 | mov r1,-(sp) 53 | asl r1 / yes. compute jump address and transfer 54 | jmp *1f-2(r1) 55 | 1: 56 | -------------------------------------------------------------------------------- /pages/e07-07: -------------------------------------------------------------------------------- 1 | ctty / tty 2 | leadr / ppt 3 | sret / mem 4 | sret / rf0 5 | sret / rk0 6 | sret / tap0 7 | sret / tap1 8 | sret / tap2 9 | sret / tap3 10 | sret / tap4 11 | sret / tap5 12 | sret / tap6 13 | sret / tap7 14 | ccvt / tty0 15 | ccvt / tty1 16 | ccvt / tty2 17 | ccvt / tty3 18 | ccvt / tty4 19 | ccvt / tty5 20 | ccvt / tty6 21 | ccvt / tty7 22 | / ejec / lpr 23 | 24 | ctty: / close console tty 25 | mov tty+[ntty*8]-8+6,r5 / point r5 to the console tty buffer 26 | decb (r5) / dec number of processes using console tty 27 | br sret / return via sret 28 | 29 | cppt: / close paper tape 30 | clrb pptiflg / set pptiflg to indicate file not open 31 | 1: 32 | mov $240,*$ps /set process or priority to 5 33 | jsr r0,getc; 2 / remove all ppt input entries from clist 34 | / and assign to free list 35 | br sret 36 | br 1b 37 | 38 | /ejec: 39 | / mov $100,*$lps / set line printer interrupt enable bit 40 | / mov $14,r1 / 'form feed' character in r1 (new page). 41 | / jsr r0,lptoc / space the printer to a new page 42 | / br sret / return to caller via 'sret' 43 | 44 | leadr: / produce paper tape leader 45 | mov $100,*$pps / set paper tape punch interrupt enable 46 | mov $100.,-(sp) / 101. characters of 'nul' will be output as 47 | / leader 48 | 1: 49 | clr r1 / r1 contains a 'nul' character 50 | jsr r0,pptoc / output the 'nul' character 51 | dec (sp) 52 | bge 1b / last leader character output? no, branch 53 | tst (sp)+ / bump stack pointer 54 | br sret / return to caller via 'sret' 55 | 56 | sysmount: / mount file system; args special; name 57 | 58 | -------------------------------------------------------------------------------- /pages/e08-01: -------------------------------------------------------------------------------- 1 | / u8 -- unix 2 | 3 | rtap: / read from the dec tape 4 | asr r1 / divide the i-number by 2 5 | sub $4.,r1 / (i-number/2)-4 r1 6 | mov r1,cdev / cdev now has device number 7 | jsr r0,bread; 578. / read in block thats in *u.fofp 8 | 9 | wtap: 10 | asr r1 / divide i-number by 2 11 | sub $4.,r1 / r1 = i-number minus 4 12 | mov r1,cdev / this is used as the device number 13 | jsr r0,bwrite; 578. / write block (u.fofp) on dec tape 14 | / Maximum 15 | 16 | rrk0: 17 | mov $1,cdev / set current device to i., disk 18 | jsr r0,bread; 4872. / read block from disk (maximum block 19 | / number allowed on device is 4872.) 20 | / - (u.fofp) contains block number 21 | 22 | wrk0: 23 | mov $1,cdev / set current device to 1; disk 24 | jsr r0,bwrite; 4872. / write block (u.fofp) on disk 25 | 26 | rrf0: 27 | clr cdev / set current device to 0., fixed head disk 28 | jsr r0,bread; 1024. / read block (u.fofp) from fixed head 29 | / disk (max. block number allowed on 30 | / device is 1024.) 31 | 32 | wrf0: 33 | clr cdev / set current device to 0., fixed head disk 34 | jsr r0,bwrite; 1024. / write block '(u.fofp)' on fixed head 35 | / disk 36 | 37 | bread: / read a block from a block structured device 38 | jsr r0,tstdeve / error on special file I/O (only works on 39 | / tape) 40 | mov *u.fofp,r1 / move block number to r1 41 | mov $2.-cold,-(sp) / "2-cold" to stack 42 | 1: 43 | cmp r1,(r0) / is this block # greater than or equal to 44 | / maximum block # allowed on device 45 | bhis 1f / yes, 1f (error) 46 | mov r1,-(sp) / no, put block # on stack 47 | jsr r0,preread / read in the block into an I/O buffer 48 | mov (sp)+,r1 / return block # to r1 49 | inc r1 / bump block # to next consecutive block 50 | dec (sp) / "2-1-cold" on stack 51 | bgt 1b / 2-1-cold = 0? No, go back and read in next block 52 | 1: 53 | tst (sp)+ / yes, pop stack to clear off cold calculation 54 | mov *u.fofp,r1 / restore r1 to initial value of the 55 | / block # 56 | -------------------------------------------------------------------------------- /pages/e08-03: -------------------------------------------------------------------------------- 1 | mov (sp)+,r0 / return to routine that called writei 2 | jmp ret 3 | tstdeve: / check whether permanent error has occured on special file 4 | / I/O 5 | mov cdev,r1 / only works on tape; r1 has device # 6 | tstb deverr(r1) / test error bit of device 7 | bne 1f / error 8 | rts r0 / device okay 9 | 1: 10 | clrb deverr(r1) / clear error 11 | 12 | error10: 13 | jmp error / see 'error' routine 14 | 15 | dioreg: 16 | mov u.count,r3 / move char count to r3 17 | cmp r3,$512. / more than 512. char? 18 | blos 1f / no, branch 19 | mov $512.,r3 / yes, just take 512. 20 | 1: 21 | mov u.base,r2 / put users base in r2 22 | add r3,u.nread / add the number to be read to u.nread 23 | sub r3,u.count / update count 24 | add r3,u.base / update base 25 | rts r0 / return 26 | 27 | preread: 28 | jsr r0,bufaloc / get a free I/O buffer (r1 has block number) 29 | br 1f / branch if block already in a I/O buffer 30 | bis $2000,(r5) / set read bit (bit 100 in I/O buffer) 31 | jsr r0,poke / perform the read 32 | 1: 33 | clr *$ps / ps = 0 34 | rts r0 35 | 36 | dskrd: 37 | jsr r0,bufaloc / shuffle off to bufaloc; get a free I/O buffer 38 | br 1f 39 | bis $2000,(r5) / set bit 10 of word 1 of I/O queue entry 40 | / for buffer 41 | jsr r0,poke / just assigned in bufaloc, bit 10=1 says read 42 | 1: 43 | clr *$ps 44 | bit $22000,(r5) / if either bits 10, or 13 are 1; jump to idle 45 | beq 1f 46 | jsr r0,idle; s.wait+2 47 | br 1b 48 | 1: 49 | add $8,r5 / r5 points to first word of data in block just read 50 | / in 51 | rts r0 52 | 53 | wslot: 54 | jsr r0,bufaloc / get a free I/O buffer; pointer to first 55 | br 1f / word in buffer in r5 56 | -------------------------------------------------------------------------------- /pages/e08-08: -------------------------------------------------------------------------------- 1 | mov tcdt,r0 / r0 has contents of data register 2 | add $3,r0 / overshoot 3 | cmp r0,2(r1) 4 | bgt 0b / if gt keep reading 5 | br taper / else reverse 6 | 7 | tape3: / I/O transfer 8 | bic $30000,(r1) / clear bits 12 and 13 of I/O queue entry 9 | jsr r0,poke / do the I/O 10 | bit $4,active / still busy see if pick up r-ahead, w-behind 11 | bne 1f / yes 12 | movb $1,(r2) / no, indicate too bad 13 | 1: 14 | jsr r0,wakeup; runq; 31. / wait up 15 | br 4f / retisp 16 | 17 | drum: / interrupt handler 18 | jsr r0,setisp / save r1,r2,r3, and clockp on the stack 19 | jsr r0,trapt; dcs; rfap; 1 / check for stray interrupt or 20 | / error 21 | br 3f / no, error 22 | br 2f / error 23 | 24 | disk: 25 | jsr r0,setisp / save r1,r2,r3, and clockp on the stack 26 | jmp *$0f 27 | 0: 28 | jsr r0,trapt; rkcs; rkap; 2 29 | br 3f / no, errors 30 | mov $115,(r2) / drive reset, errbit was set 31 | mov $1f,0b-2 / next time jmp *$0f is executed jmp will be 32 | / to 1f 33 | br 4f 34 | 1: 35 | bit $20000,rkcs 36 | beq 4f / wait for seek complete 37 | mov $0b,0b-2 38 | mov rkap,r1 39 | 2: 40 | bit $3000,(r1) / are bits 9 or 10 set in the 1st word of 41 | / the disk buffer 42 | bne 3f / no, branch ignore error if outstanding 43 | inc r1 44 | asr (r1) 45 | asr (r1) 46 | asr (r1) / reissue request 47 | dec r1 48 | 3: 49 | bic $30000,(r1) / clear bits 12 and 13 in 1st word of buffer 50 | mov ac,-(sp) 51 | mov mq,-(sp) / put these on the stack 52 | mov sc,-(sp) 53 | jsr r0,poke 54 | mov (sp)+,sc 55 | mov (sp)+,mq / pop them off stack 56 | mov (sp)+,ac 57 | -------------------------------------------------------------------------------- /pages/e08-09: -------------------------------------------------------------------------------- 1 | 4: 2 | jmp retisp / u4-3 3 | 4 | trapt: / r2 points to the 5 | mov (r0)+,r2 / device control register 6 | mov *(r0)+,r1 / transaction pointer points to buffer 7 | tst (sp)+ 8 | tstb (r2) / is ready bit of dcs set? 9 | bge 4b / device still active so branch 10 | bit (r0),active / was device busy? 11 | beq 4b / no, stray interrupt 12 | bic (r0)+,active / yes, set active to zero 13 | tst (r2) / test the err(bit is) of dcs 14 | bge 2f / if no error jump to 2f 15 | tst (r0)+ / skip on error 16 | 2: 17 | jmp (r0) 18 | -------------------------------------------------------------------------------- /pages/e09-01: -------------------------------------------------------------------------------- 1 | / u9 -- unix 2 | 3 | trcv: 4 | jsr r0,1f 5 | jsr r0,1f 6 | jsr r0,1f 7 | jsr r0,1f 8 | jsr r0,1f 9 | jsr r0,1f 10 | jsr r0,1f 11 | jsr r0,1f 12 | 1: 13 | mov r1,-(sp) 14 | mov r2,-(sp) 15 | mov r3,-(sp) 16 | mov clockp,-(sp) 17 | mov $s.syst+2,clockp 18 | sub $trcv+4,r0 / 0%4 / calculate offset for tty causing 19 | asl r0 / 0%8 / this interrupt 20 | mov rcsr(r0),r2 21 | mov rcbr(r0),r1 22 | tst r2 23 | blt 1f / error 24 | tst tty+6(r0) 25 | beq 1f 26 | bit $40,r2 / parity 27 | bne 3f / branch if set 28 | tstb tty+4(r0) 29 | blt 4f / 37 parity not allowed 30 | br 2f 31 | 3: 32 | bitb $100,tty+4(r0) 33 | beq 2f / non-37 parity not allowed 34 | 4: 35 | bic $!177,r1 36 | bit $40,tty+4(r0) 37 | bne 3f / raw 38 | cmp r1,$177 39 | beq 5f 40 | cmp r1,$34 41 | bne 3f 42 | 5: 43 | mov tty+6(r0),r0 44 | beq 2f 45 | movb r1,6(r0) / interrupt or quit 46 | jsr r0,wakeall 47 | br 2f 48 | 3: 49 | cmp r1,$15 / or 50 | bne 3f 51 | bit $20,tty+4(r0) 52 | beq 3f 53 | mov $12,r1 54 | 3: 55 | bitb $4,tty+4(r0) 56 | -------------------------------------------------------------------------------- /pages/e09-02: -------------------------------------------------------------------------------- 1 | beq 3f 2 | cmp r1,$'A 3 | blo 3f 4 | cmp r1,$'Z 5 | bhi 3f 6 | add $40,r1 7 | 3: 8 | movb tty+3(r0),0f 9 | jsr r0,putc; 0:.. / put char on input clist 10 | br 2f 11 | bitb $10,tty+4(r0) / echo 12 | bne 4f / branch echo bit set 13 | cmp r1,$12 14 | bne 3f 15 | bitb $20,tty+4(r0) / cr 16 | beq 3f 17 | 4: 18 | cmp r1,$4 / is char input an eot 19 | beq 1f 20 | mov r1,-(sp) / put char on stack 21 | movb tty+3(r0),0f 22 | inc 0f 23 | jsr r0,putc; 0:.. / put char just input on output clist 24 | br .+2 25 | jsr r0,starxmt 26 | mov (sp)+,r1 27 | 3: 28 | bitb $40,tty+4(r0) / raw 29 | bne 1f / branch if raw bit set 30 | cmp r1,$12 31 | beq 1f 32 | movb tty+3(r0),r1 33 | cmpb cc(r1),$15. 34 | blo 2f 35 | 1: 36 | movb tty+3(r0),0f 37 | jsr r0,wakeup; runq; 0:.. / call wakeup for process 38 | 2: 39 | jmp retisp 40 | txmt: 41 | jsr r0,1f 42 | jsr r0,1f 43 | jsr r0,1f 44 | jsr r0,1f 45 | jsr r0,1f 46 | jsr r0,1f 47 | jsr r0,1f 48 | jsr r0,1f 49 | 1: 50 | mov r1,-(sp) 51 | mov r2,-(sp) 52 | mov r3,-(sp) 53 | mov clockp,-(sp) 54 | mov $s.syst+2,clockp 55 | sub $txmt+4,r0 / 0%4 / offset in cc 56 | -------------------------------------------------------------------------------- /pages/e09-03: -------------------------------------------------------------------------------- 1 | asl r0 / 0%8 2 | jsr r0,starxmt 3 | jmp retisp 4 | 5 | xmtto: 6 | mov r0,-(sp) 7 | mov 2(sp),r0 / 0%2+6 8 | sub $6,r0 9 | asl r0 10 | asl r0 / 0%8 11 | jsr r0,starxmt 12 | mov (sp)+,r0 13 | rts r0 14 | 15 | starxmt: 16 | mov (sp),r1 / 0%8 r1 contains 8xtty number 17 | movb tty+3(r1),r1 / place contents of 4th byte of "tty" 18 | / buf in r1 (cc,cf,cl offset) 19 | cmpb cc+1(r1),$10. / is char count for tty output greater 20 | / than or equal to 10 21 | bhi 1f / yes 22 | mov r1,0f / no, make offset an arg of "wakeup" 23 | inc 0f / increment arg of wakeup 24 | jsr r0,wakeup; runq+2; 0:.. / wakeup process identified 25 | / by wlist 26 | 1: / entry specified by argument in 0: 27 | mov (sp),r1 / 0%8 / r1 contains tty number 28 | asr r1 29 | asr r1 30 | asr r1 / 0%1 r1 contains tty number 31 | tstb toutt+3(r1) / is tout entry for tty output = 0 32 | bne 1f / no, return to calling routine 33 | mov (sp),r2 / yes, place (8xtty number) into r2 34 | tstb tcsr(r2) / does tty's tcsr register = 0 (is ready 35 | / bit = 0) 36 | bge 1f / yes, return to calling routine 37 | movb tty+2(r2),r1 / no, place third byte of "tty" buf 38 | / into r1 (char left over after lf) 39 | clrb tty+2(r2) / clear third byte 40 | tst r1 / is third byte = 0 41 | bne 3f / no, r1 contains a non nul character 42 | movb tty+3(r2),0f / yes, make byte 4 arg of "getc" 43 | inc 0f / increment arg to make it tty output list of 44 | / clist 45 | jsr r0,getc; 0:.. / obtain next character in clist for tty 46 | / out and place in r1 47 | br 1f / if no entry in clist to be output, return to 48 | / calling routine 49 | 3: 50 | bic $!177,r1 / zero out bits 7-15 of r1 51 | movb partab(r1),r3 / move "partab" entry (identified by 52 | / r1) into r3 53 | bge 3f / if entry is greater than or equal to 0 (digit 54 | / 2, far left digit = 0) branch 55 | bisb 200,r1 / if entry is less than 0 add 128 to ASCII 56 | / code for char to be output 57 | -------------------------------------------------------------------------------- /pages/e09-04: -------------------------------------------------------------------------------- 1 | bic $!177,r3 / to make it teletype code and then clear 2 | / bits 7-15 of r3 3 | 4 | 3: 5 | mov (sp),r2 / r2 contains 8xtty number 6 | bit $4,rcsr(r2) / is carrier present for tty 7 | beq starxmt / no carrier flush 8 | mov r1,-(sp) / yes, place character to be output on stack 9 | cmp r1,$11 / is character "ht" 10 | bne 3f / no 11 | bitb $2,tty+4(r2) / is tab to space flag for tty set 12 | / (bit 1 of byte 5 in "tty" buffer area) 13 | beq 3f / no 14 | mov $240,(sp) / yes, change character to space 15 | 3: 16 | mov (sp)+,tcbr(r2) / place char to be output in tty output 17 | / buffer 18 | add $tty+1,r2 / place addr of 2nd byte of "tty" buf 19 | jmp 1f-2(r3) / area in r2 (which is the column count) and 20 | / then 21 | incb (r2) / normal / jmp to location determined by digits 22 | / 0 and 1 of character's entry in "partab" which 23 | / is now in r3 24 | 1: rts r0 / non-printing 25 | br 1f / bs 26 | br 2f / nl (line feed) 27 | br 3f / tab (horizontal tab) 28 | br 4f / vert (vertical tab) 29 | br 5f / cr 30 | 31 | 1: 32 | decb (r2) / col decrement column count in byte 2 of "tty" 33 | / area 34 | bge 1f / if count >=0 return to calling routine 35 | clrb (r2) / col set column count = 0 36 | br 1f 37 | 2: 38 | bit $1,r1 / is bit 0 of ASCII char = 1 (char = lf) 39 | bne 2f / yes 40 | bitb $20,3(r2) / cr flag is bit 4 of 5th byte of "tty" 41 | / area = 1 42 | beq 2f / no (only lf to be handled) 43 | movb $15,1(r2) / place "cr" in 3rd byte of "tty" area 44 | / (character leftover after "lf" ) 45 | 2: 46 | movb (r2),r3 / place present column count in r3 47 | beq 1f / return to calling routine if count = 0 48 | clrb (r2) / col clear column count 49 | asr r3 50 | asr r3 51 | asr r3 52 | asr r3 / delay = col/16 53 | add $3,r3 / start to determine tout entry for tty output 54 | br 2f 55 | 3: 56 | bitb $2,3(r2) / is bit 1 of 5th byte of "tty" area = 1 57 | / (tab to space bit set) 58 | -------------------------------------------------------------------------------- /pages/e09-05: -------------------------------------------------------------------------------- 1 | beq 3f / no 2 | incb (r2) / increment column count 3 | bitb $7,(r2) / are bits 0, 1 and 2 set at col 0%8 4 | beq 1f / no 5 | movb $11,1(r2) / yes, place ht in another tab next time 6 | br 1f / 3rd byte of tty area (character left over after 7 | / "lf") 8 | 3: 9 | movb (r2),r3 / place column count in r3 10 | bisb $7,(r2) / make bits 0, 1 and 2 of column count = 1 11 | incb (r2) / increment column count 12 | bis $!7,r3 / clear bits 3-15 of r3 13 | neg r3 / delay = dcol start to determine tout entry for 14 | / tty out 15 | br 2f / by neg r3 16 | 4: 17 | mov $176.,r3 / delay = lots start to determine tout entry 18 | br 2f 19 | 5: 20 | mov $10.,r3 / cr delay 160ms for tn300 start to determine 21 | / tout 22 | clrb (r2) / set column count = 0 entry 23 | 2: 24 | add $5,r3 / time for this char,increment value for tout 25 | / entry by 5 26 | mov (sp),r2 / 0%8 r2 contains 8xtty number 27 | asr r2 28 | asr r2 29 | asr r2 / 0%1 r2 contains tty number 30 | movb r3,toutt+3(r2) / place value for tout entry into tout 31 | / table 32 | 1: 33 | rts r0 / return 34 | 35 | partab: / contains 3 digits for each character; digit 2 is used 36 | / to determine if 200 is to added to ASCII code digits 0 37 | / and 1 are used to determine value for jump table. 38 | .byte 002,202,202,002,202,002,002,202 39 | .byte 204,010,006,212,012,214,202,002 40 | .byte 202,002,002,202,002,202,202,002 41 | .byte 002,202,202,002,202,002,002,202 42 | .byte 200,000,000,200,000,200,200,000 43 | .byte 000,200,200,000,200,000,000,200 44 | .byte 000,200,200,000,200,000,000,200 45 | .byte 200,000,000,200,000,200,200,000 46 | .byte 200,000,000,200,000,200,200,000 47 | .byte 000,200,200,000,200,000,000,200 48 | .byte 000,200,200,000,200,000,000,200 49 | .byte 200,000,000,200,000,200,200,000 50 | .byte 000,200,200,000,200,000,000,200 51 | .byte 200,000,000,200,000,200,200,000 52 | .byte 200,000,000,200,000,200,200,000 53 | .byte 000,200,200,000,200,000,000,202 54 | 55 | xmtt: 56 | jsr r0,cpass / get next character from user buffer area 57 | -------------------------------------------------------------------------------- /pages/e09-06: -------------------------------------------------------------------------------- 1 | tst r1 / is character nul 2 | beq xmtt / yes, get next character 3 | 1: 4 | mov $240,*$ps / set processor priority equal to 5 5 | mov (sp),r2 / r2 contains i node number of file 6 | asl r2 / 0%2+28 / multlply inode number by 2 7 | sub $21.,r2 / 0%2+7 / subtract 21 from 2x inumber to 8 | / get cc, cf, cl offset 9 | mov r2,0f / make offset arg of putc 10 | cmpb cc(r2),$50. / is char count for device greater than 11 | / or equal to 50 12 | bhis 2f / yes 13 | jsr r0,putc; 0:.. / find location in freelist to assign to 14 | / device and 15 | br 2f / place char in list, if none available branch 16 | / to put process to sleep 17 | mov r0,-(sp) / place calling routines return address on 18 | / stack 19 | mov 0b,r0 / place offset into cc, cl and cf tables in r0 20 | sub $7,r0 / subtract seven from offset 21 | asl r0 / multiply by 2 22 | asl r0 / 0%8 / multiply by 2 (r0 contains 8xtty number) 23 | jsr r0,starxmt / attempt to output character 24 | mov (sp)+,r0 / pop stack 25 | br xmtt / get next character 26 | 2: 27 | mov r1,-(sp) / place character on stack 28 | mov 0b,0f / make offset into cc, cf, cl table arg of 29 | / sleep (identifies location in wlist) 30 | jsr r0,sleep; 0:.. / put process to sleep 31 | mov (sp)+,r1 / remove character from stack 32 | br 1b / try again 33 | 34 | rcvt: / read tty 35 | sub $28.,r1 / 0%2 r1 contains 2xtty number 36 | asl r1 37 | asl r1 / r1 contains 8xtty number 38 | mov r1,-(sp) 39 | mov tty+6(r1),r5 / r5 contains address of 4th word in 40 | / tty area 41 | tst 2(r5) / is char count = 0 42 | bne 1f / no 43 | bitb $40,tty+4(r1) / raw flag set? 44 | beq 2f / no 45 | tst -(sp) / yes, decrement sp 46 | jsr r0,rcvch / get character from clist 47 | tst (sp)+ / increment sp 48 | mov (sp)+,r2 / r2 contains 8xtty number 49 | bitb $4,rcsr(r2) / is carrier detect bit on 50 | beq 3f / no 51 | jsr r0,passc / yes, place character in users buffer area 52 | 3: 53 | jmp ret 54 | 2: 55 | jsr r0,canon; rcvch / process a line of characters in 56 | / clist and place results in tty buffer 57 | -------------------------------------------------------------------------------- /pages/e09-07: -------------------------------------------------------------------------------- 1 | / area 2 | 1: 3 | tst (sp)+ / increment sp 4 | 1: 5 | tst 2(r5) / is char count for tty buffer = 0 6 | beq 1f / yes 7 | movb *4(r5),r1 / no, move character pointer to r1 8 | inc 4(r5) / increment character pointer 9 | dec 2(r5) / decrement character count 10 | jsr r0,passc / place character, whose address is in 11 | / r1, in 12 | br 1b / user buffer area. Then get next character. 13 | 1: 14 | jmp ret 15 | 16 | rcvch: 17 | mov 4(sp),r2 / 0%8 r2 contains 8xtty number 18 | mov $4,r1 19 | bit r1,rcsr(r2) / is carrier detection bit on 20 | bne 1f / yes 21 | bic $1,rcsr(r2) / no, clear data terminal ready bit 22 | rts r0 23 | 1: 24 | movb tty+3(r2),0f / make cc offset arg for "getc" 25 | mov $240,*$ps / set processor priority = 5 26 | jsr r0,getc; 0:.. / get next character off clist 27 | br 2f / clist empty 28 | clr *$ps / set processor priority = 0 29 | rts r0 30 | 2: 31 | mov 0b,0f / make "getc" arg an arg for "sleep" 32 | mov r5,-(sp) / save tty buffer address on stack 33 | jsr r0,sleep; 0:.. 34 | mov (sp)+,r5 35 | br rcvch 36 | 37 | ocvt: 38 | sub $28.,r1 / 0%2 calculate tty table offset 39 | mov r1 ,r2 40 | asl r1 / 0%4 41 | asl r1 / 0%8 42 | mov r1,-(sp) 43 | add $6,r2 / calculate clist id clist offset 44 | movb r2,tty+3(r1) / put clist id in tty table 45 | 1: 46 | mov (sp),r1 47 | bit $4,rcsr(r1) / carrier detect bit set 48 | bne 1f / if so, branch 49 | mov $511,rcsr(r1) / set ready, speed, interrupt enable, 50 | / supervisor transmit 51 | movb tty+3(r1),0f / put clist id in sleep argument 52 | jsr r0,sleep; 0:.. 53 | br 1b 54 | 1: 55 | mov tty+6(r1),r5 / put tty buffer address in r5 56 | tstb (r5) / first byte of tty buffer = 0 57 | -------------------------------------------------------------------------------- /pages/e09-08: -------------------------------------------------------------------------------- 1 | bne 1f / if not, branch 2 | mov $511,rcsr(r1) / set control bits for receiver 3 | mov $511,tcsr(r1) / set control bits for transmitter 4 | movb $210,tty+4(r1) / put 210 in tty table word 3 / set flags 5 | 1: 6 | incb (r5) / inc first byte of tty buffer 7 | tst (sp)+ 8 | tst u.ttyp / is there a process control tty 9 | bne 1f / yes, then branch 10 | mov r5,u.ttyp / no, make this tty the process control tty 11 | br 1f / return 12 | 13 | ccvt: 14 | sub $28.,r1 15 | asl r1 / 0%4 16 | asl r1 17 | mov tty+6(r1),r5 18 | decb (r5) 19 | 1: 20 | jmp sret 21 | 22 | -------------------------------------------------------------------------------- /pages/e10-01: -------------------------------------------------------------------------------- 1 | / ux -- unix 2 | 3 | systm: 4 | 5 | .=.+2 6 | .=.+128. 7 | .=.+2 8 | .=.+64. 9 | s.time: .=.+4 10 | s.syst: .=.+4 11 | s.wait: .=.+4 12 | s.idlet:.=.+4 13 | s.chrgt:.=.+4 14 | s.drerr:.=.+2 15 | inode: 16 | i.flgs: .=.+2 17 | i.nlks: .=.+1 18 | i.uid: .=.+1 19 | i.size: .=.+2 20 | i.dskp: .=.+16. 21 | i.ctim: .=.+4 22 | i.mtim: .=.+4 23 | . = inode+32. 24 | mount: .=.+1024. 25 | proc: 26 | p.pid: .=.+[2*nproc] 27 | p.dska: .=.+[2*nproc] 28 | p.ppid: .=.+[2*nproc] 29 | p.break:.=.+[2*nproc] 30 | p.link: .=.+nproc 31 | p.stat: .=.+nproc 32 | tty: 33 | . = .+[ntty*8.] 34 | fsp: .=.+[nfiles*8.] 35 | bufp: .=.+[nbuf*2]+6 36 | sb0: .=.+8 37 | sb1: .=.+8 38 | swp: .=.+8 39 | ii: .=.+2 40 | idev: .=.+2 41 | cdev: .=.+2 42 | deverr: .=.+12. 43 | active: .=.+2 44 | rfap: .=.+2 45 | rkap: .=.+2 46 | tcap: .=.+2 47 | tcstate:.=.+2 48 | tcerrc: .=.+2 49 | mnti: .=.+2 50 | mntd: .=.+2 51 | mpid: .=.+2 52 | clockp: .=.+2 53 | rootdir:.=.+2 54 | toutt: .=.+16.; touts: .=.+32. 55 | runq: .=.+6 56 | 57 | -------------------------------------------------------------------------------- /pages/e10-02: -------------------------------------------------------------------------------- 1 | wlist: .=.+40. 2 | cc: .=.+30. 3 | cf: .=.+31. 4 | cl: .=.+31. 5 | clist: .=.+510. 6 | imod: .=.+1 7 | smod: .=.+1 8 | mmod: .=.+1 9 | uquant: .=.+1 10 | sysflg: .=.+1 11 | pptiflg:.=.+1 12 | ttyoch: .=.+1 13 | .even 14 | .=.+100.; sstack: 15 | buffer: .=.+[ntty*140.] 16 | .=.+[nbuf*520.] 17 | 18 | . = core-64. 19 | user: 20 | u.sp: .=.+2 21 | u.usp: .=.+2 22 | u.r0: .=.+2 23 | u.cdir: .=.+2 24 | u.fp: .=.+10. 25 | u.fofp: .=.+2 26 | u.dirp: .=.+2 27 | u.namep: .=.+2 28 | u.off: .=.+2 29 | u.base: .=.+2 30 | u.count: .=.+2 31 | u.nread: .=.+2 32 | u.break: .=.+2 33 | u.ttyp: .=.+2 34 | u.dirbuf:.=.+10. 35 | u.pri: .=.+2 36 | u.intr: .=.+2 37 | u.quit: .=.+2 38 | u.emt: .=.+2 39 | u.ilgins:.=.+2 40 | u.cdev: .=.+2 41 | u.uid: .=.+1 42 | u.ruid: .=.+1 43 | u.bsys: .=.+1 44 | u.uno: .=.+1 45 | . = core 46 | 47 | -------------------------------------------------------------------------------- /pages/e11-01: -------------------------------------------------------------------------------- 1 | / sh -- command interpreter 2 | mov sp,r5 3 | mov r5,shellarg / save orig sp in shellarg 4 | cmpb *2(r5),$'- / was this sh calleZd by init or loginx~ 5 | bne 2f / no 6 | sys intr; 0 / yes, turn off interrupts 7 | sys quit; 0 8 | 2: 9 | sys getuid / who is user 10 | tst r0 / is it superuser 11 | bne 2f / no 12 | movb $'#,at / yes, set new prompt symbol 13 | 2: 14 | cmp (r5),$1 / tty input? 15 | ble newline / yes, call with '-(or with no command 16 | / file name) 17 | clr r0 / no, set ttv 18 | sys close / close it 19 | mov 4(r5),0f / get new file name 20 | sys open; 0:..; 0 / open it 21 | bec 1f / branch if no error 22 | jsr r5,error / error in file name 23 | ; .even 24 | sys exit 25 | 1: 26 | clr at / clear prompt character, if reading non-tty 27 | / input file 28 | newline: 29 | tst at / is there a prompt symbol 30 | beq newcom / no 31 | mov $1,r0 / yes 32 | sys write; at; 2. / print prompt 33 | newcom: 34 | mov shellarg,sp / 35 | mov $parbuf,r3 / initialize command list area 36 | mov $parp,r4 / initialize command list pointers 37 | clr infile / initialize alternate input 38 | clr outfile / initialize alternate output 39 | clr glflag / initialize global flag 40 | newarg: 41 | jsr pc,blank / squeeze out leading blanks 42 | jsr r5,delim / is new character a ; \n or & 43 | br 2f / yes 44 | mov r3,-(sp) / no, push arg pointer onto stack 45 | cmp r0,$'< / new input file? 46 | bne 1f / no 47 | mov (sp),infile / yes, save arg pointer 48 | clr (sp) / clear pointer 49 | br 3f 50 | 1: 51 | cmp r0,$'> / new output file? 52 | bne newchar / no 53 | mov (sp),outfile / yes, save arg pointer 54 | clr (sp) / clear pointer 55 | br 3f 56 | -------------------------------------------------------------------------------- /pages/e11-02: -------------------------------------------------------------------------------- 1 | newchar: 2 | cmp $' ,r0 / is character a blank 3 | beq 1f / branch if it is (blank as arg separator) 4 | cmp $'\n+200,r0 / treat \n preceded by \ 5 | beq 1f / as blank 6 | jsr pc,putc / put this character in parbuf list 7 | 3: 8 | jsr pc,getc / get next character 9 | jsr r5,delim / is char a ; \n or &, 10 | br 1f / yes 11 | br newchar / no, start new character tests 12 | 1: 13 | clrb (r3)+ / end name with \0 when read blank, or 14 | / delim 15 | mov (sp)+,(r4)+ / move arg ptr to parp location 16 | bne 1f / if (sp)=0, in file or out file points to arg 17 | tst -(r4) / so ignore dummy (0), in pointer list 18 | 1: 19 | jsr r5,delim / is char a ; \n or &. 20 | br 2f / yes 21 | br newarg / no, start newarg processing 22 | 2: 23 | clr (r4) / \n, &, or ; takes to here (end of arg list) 24 | / after 'delim' call 25 | mov r0,-(sp) / save delimter in stack 26 | jsr pc,docom / go to exec command in parbuf 27 | cmpb (sp),$'& / get a new command without wait? 28 | beq newcom / yes 29 | tst r1 / was chdir just executed or line ended with 30 | / ampersand? 31 | beq 2f / yes 32 | 1: 33 | sys wait / no, wait for new process to terminate 34 | / command executed) 35 | bcs 2f / no, children not previously waited for 36 | cmp r0,r1 / is this my child 37 | bne 1b 38 | 2: 39 | cmp (sp),$'\n / was delimiter a new line 40 | beq newline / yes 41 | br newcom / no, pick up next command 42 | docom: 43 | sub $parp,r4 / out arg count in r4 44 | bne 1f / any arguments? 45 | clr r1 / no, line ended with ampersand 46 | rts pc / return from call 47 | 1: 48 | jsr r5,chcom; qchdir / is command chdir? 49 | br 2f / command not chdir 50 | cmp r4,$4 / prepare to exec chdir, 4=arg count x 2 51 | beq 3f 52 | jsr r5,error / go to print error 53 | ; .even 54 | br 4f 55 | 3: 56 | -------------------------------------------------------------------------------- /pages/e11-03: -------------------------------------------------------------------------------- 1 | mov parp+2,0f / more directory name to sys coll 2 | sys chdir; 0:0 / exec chdir 3 | bec 4f / no error exit 4 | jsr r5,error / go to print error 5 | ; .even / this diagnostic 6 | 4: 7 | clr r1 / set r1 to zero to dkip wait 8 | rts pc / and return 9 | 2: 10 | jsr r5,chcom; glogin / is command login? 11 | br 2f / not loqin, go to fork 12 | sys exec; parbuf; parp / exec login 13 | sys exec; binpb; parp / or /bin/login 14 | 2: / no error return?? 15 | sys fork / generate sh child process for command 16 | br newproc / exec command with new process 17 | bec 1f / no error exit, old orocess 18 | jsr r5,error / go to print error 19 | ; .even / this diaonostic 20 | jmp newline / and return for next try 21 | 1: 22 | mov r0,r1 / save id of child sh 23 | rts pc / return to "jsr pc, docom" call in parent sh 24 | 25 | error: 26 | movb (r5)+,och / pick up diagnostic character 27 | beq 1f / 0 is end of line 28 | mov $1,r0 / set for tty output 29 | sys write; och; 1 / print it 30 | br error / continue to get characters 31 | 1: 32 | inc r5 / inc r5 to point to return 33 | bic $1,r5 / make it even 34 | clr r0 / set for input 35 | sys seek; 0; 2 / exit from runcom. skip to end of 36 | / input file 37 | chcom: / has no effect if tty input 38 | mov (r5)+,r1 / glogin gchdir r1, bump r5 39 | mov $parbuf,r2 / command address r2 'login' 40 | 1: 41 | movb (r1)+,r0 / is this command 'chdir' 42 | cmpb (r2)+,r0 / compare command name byte with 'login' 43 | / or 'chdir' 44 | bne 1f / doesn't compare 45 | tst r0 / is this 46 | bne 1b / end of names 47 | tst (r5)+ / yes, bump r5 again to execute login 48 | / chdir 49 | 1: 50 | rts r5 / no, return to exec command 51 | 52 | putc: 53 | cmp r0,$'' / single quote? 54 | beq 1f / yes 55 | cmp r0,$'" / double quote 56 | beq 1f / yes 57 | -------------------------------------------------------------------------------- /pages/e11-04: -------------------------------------------------------------------------------- 1 | bic $!177,r0 / no, remove 200, if present 2 | movb r0,(r3)+ / store character in parbuf 3 | rts pc 4 | 1: 5 | mov r0,-(sp) / push quote mark onto stack 6 | 1: 7 | jsr pc,getc / get a quoted character 8 | cmp r0,$'\n / is it end or line 9 | bne 2f / no 10 | jsr r5,error / yes, indicate missing quote mark 11 | <"' imbalance\n\0>; .even 12 | jmp newline / ask for new line 13 | 2: 14 | cmp r0,(sp) / is this closing quote mark 15 | beq 1f / yes 16 | bic $!177,r0 / no, strip off 200 if present 17 | movb r0,(r3)+ / store quoted character in parbuf 18 | br 1b / continue 19 | 1: 20 | tst (sp)+ / pop quote mark off stack 21 | rts pc / return 22 | 23 | / thp`e new process 24 | 25 | newproc: 26 | mov infile,0f / move pointer to new file name 27 | beq 1f / branch if no alternate read file given 28 | tstb *0f 29 | beq 3f / branch if no file name miven 30 | clr r0 / set tty input file name 31 | sys close / close it 32 | sys open; 0:..; 0 / open new input file for reading 33 | bcc 1f / branch if input file ok 34 | 3: 35 | jsr r5,error / file not ok, print error 36 | ; .even / this diagnostic 37 | sys exit / terminate this process and make parent sh 38 | 1: 39 | mov outfile,r2 / more pointer to new file name 40 | beq 1f / branch if no alternate write file 41 | cmpb (r2),$'> / is > at beqinninrg of file name? 42 | bne 4f / branch if it isn't 43 | inc r2 / yes, increment pointer 44 | mov r2,0f 45 | sys open; 0:..; 1 / open file for writing 46 | bec 3f / if no error 47 | 4: 48 | mov r2,0f 49 | sys creat; 0:..; 17 / create new file with this name 50 | bec 3f / branch if no error 51 | 2: 52 | jsr r5,error 53 | ; .even 54 | sys exit 55 | 3: 56 | sys close / close the new write file 57 | -------------------------------------------------------------------------------- /pages/e11-05: -------------------------------------------------------------------------------- 1 | mov r2,0f / move new name to open 2 | mov $1,r0 / set ttv file name 3 | sys close / close it 4 | sys open; 0:..; 1 / open new output file, it now has 5 | / file descriptor 1 6 | sys seek; 0; 2 / set pointer to current end of file 7 | 1: 8 | tst glflag / was *, ? or [ encountered? 9 | bne 1f / yes 10 | sys exec; parbuf; parp / no, execute this commend 11 | sys exec; binpb; parp / or /bin/this command 12 | 2: 13 | sys stat; binpb; inbuf / if can't execute does it 14 | / exist? 15 | bes 2f / branch if it doesn't 16 | mov $shell,parp-2 / does exist, not executable 17 | mov $binpb,parp / so it must be 18 | sys exec; shell; parp-2 / a command file, get it with 19 | / sh /bin/x (if x name of file) 20 | 2: 21 | jsr r5,error / a return for exec is the diagnostic 22 | ; .even 23 | sys exit 24 | 1: 25 | mov $glob,parp-2 / prepare to process *,? 26 | sys exec; glob; parp-2 / execute modified command 27 | br 2b 28 | 29 | delim: 30 | cmp r0,$'\n / is character a newline 31 | beq 1f 32 | cmp r0,$'& / is it & 33 | beq 1f / yes 34 | cmp r0,$'; / is it ; 35 | beq 1f / yes 36 | cmp r0,$'? / is it ? 37 | beq 3f 38 | cmp r0,$'[ / is it beginning of character string 39 | / (for glob) 40 | bne 2f 41 | 3: 42 | inc glflag / ? or * or [ set flag 43 | 2: 44 | tst (r5)+ / bump to process all except \n,;,& 45 | 1: 46 | rts r5 47 | 48 | blank: 49 | jsr pc,getc / get next character 50 | cmp $' ,r0 / leading blanks 51 | beq blank / yes, 'squeeze out' 52 | cmp r0,$200+'\n / new-line preceded by \ is translated 53 | beq blank / into blank 54 | rts pc 55 | getc: 56 | -------------------------------------------------------------------------------- /pages/e11-06: -------------------------------------------------------------------------------- 1 | tst param / are we substituting for $n 2 | bne 2f/ yes 3 | mov inbufp,r1 / no, move normal input pointer to r1 4 | cmp r1,einbuf / end of input line? 5 | bne 1f / no 6 | jsr pc,getbuf / yes, put next console line in buffer 7 | br getc 8 | 1: 9 | movb (r1)+,r0 / move byte from input buffer to r0 10 | mov r1,inbufp / increment routine 11 | bis escap,r0 / if last character was \ this adds 12 | / 200 to current character 13 | clr escap / clear, so escap normally zero 14 | cmp r0,$'\\ / note that \\ is equal \ in as 15 | beq 1f 16 | cmp r0,$'$ / is it $ 17 | beq 3f / yes 18 | rts pc / no 19 | 1: 20 | mov $200,escap / mark presence of \ in command line 21 | br getc / get next character 22 | 2: 23 | movb *param,r0 / pick up substitution character put in 24 | / r0 25 | beq 1f / if end of substitution arg, branch 26 | inc param / if not end, set for next character 27 | rts pc / return as though character in ro is normal 28 | / input 29 | 1: 30 | clr param / unset substitution pointer 31 | br getc / get next char in normal input 32 | 3: 33 | jsr pc,getc / get digit after $ 34 | sub $'0,r0 / strip off zone bits 35 | cmp r0,$9. / compare with digit 9 36 | blos 1f / less than or equal 9 37 | mov $9.,r0 / if larger than 9, force 9 38 | 1: 39 | mov shellarg,r1 / get pointer to stack for 40 | / this call of shell 41 | inc r0 / digit +1 42 | cmp r0,(r1) / is it less than # of args in this call 43 | bge getc / no, ignore it. so this $n is not replaced 44 | asl r0 / yes, multiply by 2 (to skip words) 45 | add r1,r0 / form pointer to arg pointer (-2) 46 | mov 2(r0),param / move arg pointer to param 47 | br getc / go to get substitution arg for $n 48 | getbuf: 49 | mov $inbuf,r0 / move input buffer address 50 | mov r0,inbufp / to input buffer pointer 51 | mov r0,einbuf / and initialize pointer to end of 52 | / character string 53 | dec r0 / decrement pointer so can utilize normal 54 | / 100p starting at 1f 55 | mov r0,0f / initialize address for reading 1st char 56 | -------------------------------------------------------------------------------- /pages/e11-07: -------------------------------------------------------------------------------- 1 | 1: 2 | inc 0f / this routine filles inbuf with line from 3 | / console - if there is cnc 4 | clr r0 / set for tty input 5 | sys read; 0:0; 1 / read next char into inbuf 6 | bcs xit1 / error exit 7 | tst r0 / a zero input is end of file 8 | beq xit1 / exit 9 | inc einbuf / eventually einbuf points to \n 10 | / (+1) of this line 11 | cmp 0b,$inbuf+256. / have we exceeded input buffer size 12 | bhis xit1 / if so, exit assume some sort of binary 13 | cmpb *0b,$'\n / end of line? 14 | bne 1b / no, go to get next char 15 | rts pc / yes, return 16 | 17 | xit1: 18 | sys exit 19 | 20 | quest: 21 | 22 | 23 | at: 24 | <@ > 25 | 26 | qchdir: 27 | 28 | glogin: 29 | 30 | shell: 31 | 32 | glob: 33 | 34 | binpb: 35 | 36 | parbuf: .=.+1000. 37 | .even 38 | param: .=.+2 39 | glflag: .=.+2 40 | infile: .=.+2 41 | outfile:.=.+2 42 | .=.+2 / room for glob 43 | parp: .=.+200. 44 | inbuf: .=.+256. 45 | escap: .=.+2 46 | inbufp: .=.+2 47 | einbuf: .=.+2 48 | och: .=.+2 49 | shellarg:.=.+2 50 | 51 | -------------------------------------------------------------------------------- /pages/e12-01: -------------------------------------------------------------------------------- 1 | / init -- process control initialization 2 | 3 | mount = 21. 4 | 5 | sys intr; 0 / turn off interrupts 6 | sys quit; 0 7 | cmp csw,$73700 / single user? 8 | bne 1f / no 9 | help: 10 | clr r0 / yes 11 | sys close / close current read 12 | mov $1,r0 / and write 13 | sys close / files 14 | sys open; ctty; 0 / open control tty 15 | sys open; ctty; 1 / for read and write 16 | sys exec; shell; shellp / execute shell 17 | br help / keep trying 18 | 1: 19 | mov $'0,r1 / prepare to change 20 | 1 : 21 | movb r1,tapx+8 / mode of dec tape drive x, where 22 | sys chmod; tapx; 17 / x=0 to 7, to read/write by owner or 23 | inc r1 / non-owner mode 24 | cmp r1,$'8 / finished? 25 | blo 1b / no 26 | sys mount; rk0; usr / yes, root file on mounted rko5 27 | / disk ls /usr 28 | sys creat; utmp; 16 / truncate /tmp/utmp 29 | sys close / close it 30 | movb $'x,zero+8. / put identifier in output buffer 31 | jsr pc,wtmprec / go to write accting info 32 | mov $itab,r1 / address of table to r1 33 | 34 | / create shell processes 35 | 36 | 1: 37 | mov (r1)+,r0 / 'x, x=0, 1... to r0 38 | beq 1f / branch if table end 39 | movb r0,ttyx+8 / put symbol in ttyx 40 | jsr pc,dfork / go to make new init for this ttyx 41 | mov r0,(r1)+ / save child id in word offer '0, '1,...etc. 42 | br 1b / set up next child 43 | 44 | / wait for process to die 45 | 46 | 1: 47 | sys wait / wait for user to terminate process 48 | mov $itab,r1 / initialize for search 49 | 50 | / search for process id 51 | 52 | 2: 53 | tst (r1)+ / bump r1 to child id location 54 | beq 1b / ? something silly 55 | cmp r0,(r1)+ / which process has terminated 56 | -------------------------------------------------------------------------------- /pages/e12-02: -------------------------------------------------------------------------------- 1 | bne 2b / not this one 2 | 3 | / take name out of utmp 4 | 5 | sub $4, r1 / process is found, point x' to 'x 6 | / for it 7 | mov r1,-(sp) / save address on stack 8 | mov (r1),r1 / move 'x to r1 9 | sub $'0,r1 / remove zone bits from character 10 | asl r1 / generate proper 11 | asl r1 / offset 12 | asl r1 / for 13 | asl r1 / seek 14 | mov r1,0f / move it to offset loc for seek 15 | mov $zero,r1 16 | 2: 17 | clr (r1)+ / ccear- 18 | cmp r1,$zero+16. / output buffer 19 | blo 2b / area 20 | sys open; utmp; 1 / open file for writing 21 | bes 2f / if can't open, create user anyway 22 | mov r0,r1 / save file desc 23 | sys seek; 0:..; 0 / move to proper pointer position 24 | mov r1,r0 / not required 25 | sys write; zero; 16. / zero this position in 26 | mov r1,r0 / restore file descriptor 27 | sys close / close file 28 | 29 | / re-create user process 30 | 31 | 2: 32 | mov (sp)+,r1 / restore 'x to r1 33 | mov (r1)+,r0 / move it to r0 34 | movb r0,ttyx+8 / get correct ttyx 35 | movb r0,zero+8 / move identifier to output buffer 36 | jsr pc,wtmprec / go to write accting into 37 | jsr pc,dfork / fork 38 | mov r0,(r1)+ / save id of child 39 | br 1b / go to wait for next process end 40 | 41 | dfork: 42 | mov r1,r2 43 | sub $itab+2,r2 / left over 44 | asl r2 / from previous 45 | asl r2 / version of code 46 | mov r2,offset 47 | sys fork 48 | br 1f / to new copy of init 49 | bes dfork / try again 50 | rts pc / return 51 | 1 : 52 | sys quit; 0 / new init turns off 53 | sys intr; 0 / interrupts 54 | sys chown; ttyx; 0 / change owner to super user 55 | sys chmod; ttyx; 15 / changemode to read/write owner, 56 | / write non-owner 57 | -------------------------------------------------------------------------------- /pages/e12-03: -------------------------------------------------------------------------------- 1 | sys open; ttyx; 0 / open this ttyx for reading 2 | / and wait until someone calls 3 | bes help1 / branch if trouble 4 | sys open; ttyx; 1 / open this ttyx for writing after 5 | / user call 6 | bes help1 / branch if trouble 7 | sys exec; getty; gettyp / getty types and 8 | / executes login which logs user 9 | / in and executes sh- 10 | sys exit / HELP! 11 | 12 | help1: 13 | jmp help / trouble 14 | 15 | wtmprec: 16 | sys time / get time 17 | mov ac,zero+10. / more to output 18 | mov mq,zero+12. / buffer 19 | sys open; wtmp; 1 / open accounting file 20 | bes 2f 21 | mov r0,r2 / save file descriptor 22 | sys seek; 0; 2 / move pointer to end of file 23 | mov r2,r0 / not required 24 | sys write; zero; 16. / write accting info 25 | mov r2,r0 / restore file descriptor 26 | sys close / close file 27 | 2: 28 | rts pc 29 | 30 | ctty: 31 | shell: 32 | shellm: <-\0> 33 | tapx: 34 | rk0: 35 | utmp: 36 | wtmp: 37 | ttyx: 38 | getty: 39 | usr: 40 | .even 41 | 42 | shellp: shellm 43 | 0 44 | gettyp: getty 45 | 0 46 | itab: 47 | '0; .. 48 | '1; .. 49 | '2; .. 50 | '3; .. 51 | '4; .. 52 | '5; .. 53 | '6; .. 54 | '7; .. 55 | 0 56 | -------------------------------------------------------------------------------- /pages/e12-04: -------------------------------------------------------------------------------- 1 | 2 | offset: .=.+2 3 | zero: .=.+8; .=.+6; .=.+2 4 | -------------------------------------------------------------------------------- /patches/cold.patch: -------------------------------------------------------------------------------- 1 | diff -ru rebuilt/u0.s build/u0.s 2 | --- rebuilt/u0.s 2008-05-03 08:27:03.000000000 -1000 3 | +++ build/u0.s 2008-05-04 08:29:31.000000000 -1000 4 | @@ -1,6 +1,6 @@ 5 | / u0 -- unix 6 | 7 | -cold = 0 8 | +cold = 1 9 | orig = 0 . / orig = 0. relocatable 10 | 11 | rkda = 177412 / disk address reg rk03/rk11 12 | -------------------------------------------------------------------------------- /patches/core/aout407.patch: -------------------------------------------------------------------------------- 1 | diff -ru rebuilt/u2.s build/u2.s 2 | --- rebuilt/u2.s 2008-05-04 15:29:30.000000000 -1000 3 | +++ build/u2.s 2008-05-04 15:45:52.000000000 -1000 4 | @@ -177,6 +177,33 @@ 5 | / number of words less 26 available for 6 | / program in user core 7 | mov r5,u.count / 8 | + 9 | + / 0407 binary support added may 2008. 10 | + br 1f 11 | +bsz: 0 / XXX is there a reg that I can use over a call to readi? 12 | +1: 13 | + cmp core,$407 14 | + bne e407 15 | + add $4,u.off / skip last two header words 16 | + mov $core,r4 17 | + mov r4,u.base / continue reading at core. 18 | + mov core+2,r5 19 | + add core+4,r5 / r5 = text+data size 20 | + mov core+6,bsz / save bss size, we're going to overwrite core 21 | + / XXX fix me, I dont quite understand what to do here or 22 | + / what is done in the similar code below e407: 23 | + / cmp r5, u.count / see if theres enough room 24 | + / bgt 1f 25 | + mov r5,u.count / read text+data into core 26 | + jsr r0,readi 27 | + mov u.nread,u.break / break = core + nread + bss 28 | + add $core,u.break 29 | + add bsz,u.break 30 | + jsr r0,iclose 31 | + br sysret3 32 | +e407: 33 | + / end 0407 support 34 | + 35 | cmp core,$405 / br .+14 is first instruction if file is 36 | / standard a.out format 37 | bne 1f / branch, if not standard format 38 | -------------------------------------------------------------------------------- /patches/core/ecore.patch: -------------------------------------------------------------------------------- 1 | --- rebuilt/u0.s Mon May 5 17:57:35 2008 2 | +++ build/u0.s Mon May 5 17:57:54 2008 3 | @@ -43,7 +43,7 @@ 4 | .endif 5 | 6 | core = orig+40000 / specifies beginning of user's core 7 | -ecore = core+20000 / specifies end of user's core (4096 words) 8 | +ecore = core+40000 / specifies end of user's core (4096 words) 9 | 10 | 4;4 / init by copy 11 | unkni;0 / " error 12 | @@ -159,9 +162,9 @@ 13 | 14 | mov $1024.-64.,r1 / highest drum address; high 64 blks allocated 15 | / to UNIX 16 | - mov $p.dska,r2 / p.dska contains dis addresses for processes 17 | + mov $p.dska,r2 / p.dska contains disk addresses for processes 18 | 1 : 19 | - sub $17.,r1 / 17 blocks per process 20 | + sub $33.,r1 / 33 blocks per process, allows 16K per process 21 | mov r1,(r2)+ 22 | cmp r2,$p.dska+nproc+nproc 23 | bne 1b 24 | -------------------------------------------------------------------------------- /patches/core/fastout.patch: -------------------------------------------------------------------------------- 1 | --- rebuilt/u4.s Mon May 5 21:40:27 2008 2 | +++ build/u4.s Mon May 5 21:39:35 2008 3 | @@ -214,13 +214,14 @@ 4 | bne 1f 5 | movb $15,ttyoch / put a cr in ttyoch 6 | 1: 7 | - cmp r1,$11 / char = ht 8 | - bne 1f 9 | - movb $15.,toutt+0 / set time out to 15 clock tics 10 | + / output delays removed, we don't have mechanical ttys, May 5 2008 11 | + / cmp r1,$11 / char = ht 12 | + / bne 1f 13 | + / movb $15.,toutt+0 / set time out to 15 clock tics 14 | 1: 15 | - cmp r1,$15 / char = cr 16 | - bne 2f 17 | - movb $15.,toutt+0 / set time out to 15 clock ticks 18 | + / cmp r1,$15 / char = cr 19 | + / bne 2f 20 | + / movb $15.,toutt+0 / set time out to 15 clock ticks 21 | 2: 22 | rts r0 23 | pptito: / paper tape input touts subrouting 24 | -------------------------------------------------------------------------------- /patches/core/initorig.patch: -------------------------------------------------------------------------------- 1 | --- build/init.s 2008-06-25 08:39:57.000000000 -1000 2 | +++ build/init.s 2008-06-25 08:40:08.000000000 -1000 3 | @@ -1,4 +1,5 @@ 4 | / init -- process control initialization 5 | +.. = 40014 6 | 7 | mount = 21. 8 | 9 | @@ -163,6 +164,7 @@ 10 | '5; .. 11 | '6; .. 12 | '7; .. 13 | + '8; .. 14 | 0 15 | 16 | offset: .=.+2 17 | -------------------------------------------------------------------------------- /patches/core/shell.patch: -------------------------------------------------------------------------------- 1 | --- build/sh.clean 2008-05-11 10:41:44.000000000 -1000 2 | +++ build/sh.s 2008-05-11 10:42:49.000000000 -1000 3 | @@ -142,6 +146,8 @@ 4 | inc r5 / inc r5 to point to return 5 | bic $1,r5 / make it even 6 | clr r0 / set for input 7 | + rts r5 8 | + 9 | sys seek; 0; 2 / exit from runcom. skip to end of 10 | / input file 11 | chcom: / has no effect if tty input 12 | @@ -257,6 +255,8 @@ 13 | beq 1f / yes 14 | cmp r0,$'? / is it ? 15 | beq 3f 16 | + cmp r0,$'* / is it * 17 | + beq 3f 18 | cmp r0,$'[ / is it beginning of character string 19 | / (for glob) 20 | bne 2f 21 | -------------------------------------------------------------------------------- /patches/core/shorig.patch: -------------------------------------------------------------------------------- 1 | --- rebuilt/sh.clean 2008-05-07 18:44:47.000000000 -1000 2 | +++ build/sh.s 2008-05-07 18:50:26.000000000 -1000 3 | @@ -1,4 +1,6 @@ 4 | / sh -- command interpreter 5 | +.. = 40014 6 | + 7 | mov sp,r5 8 | mov r5,shellarg / save orig sp in shellarg 9 | cmpb 8(r5),$'- / was this sh calleZd by init or loginx~ 10 | -------------------------------------------------------------------------------- /patches/core/upcase.patch: -------------------------------------------------------------------------------- 1 | --- rebuilt/u4.s Wed May 7 01:50:25 2008 2 | +++ build/u4.s Wed May 7 09:50:17 2008 3 | @@ -73,17 +73,24 @@ 4 | inc *$tks / set the reader enable bit 5 | bic $!177,r1 / clear upper 9 bits of the character (strip off 6 | / 8th bit of char) 7 | - cmp r1,$'a-40 / is character upper case A,..., upper case Z. 8 | + / cr to lf conversion May 7 2008 9 | + cmp r1,$15 / if we receive a cr 10 | + bne 0f 11 | + mov $12,r1 / convert it into an lf 12 | +0: 13 | + / uppercase to lowercase conversion removed May 5 2008 14 | + / cmp r1,$'a-40 / is character upper case A,..., upper case Z. 15 | / note that 16 | - blt 1f / lower case a is represented by 141, upper case by 17 | - cmp r1,$'z-40 / 101; and lower case z by 172, upper 18 | + / blt 1f / lower case a is represented by 141, upper case by 19 | + / cmp r1,$'z-40 / 101; and lower case z by 172, upper 20 | / case Z by 132. 21 | - bgt 1f / if not upper case, branch 22 | - add $40,r1 / if upper case, calculate the representation of its 23 | + / bgt 1f / if not upper case, branch 24 | + / add $40,r1 / if upper case, calculate the representation of its 25 | / lower case counter part 26 | 1: 27 | - cmp r1,$175 / char = "}"? Note: may be quit char (fs) 28 | - beq 2f / yes 2f 29 | + / deletion of } characters removed May 5 2008 30 | + / cmp r1,$175 / char = "}"? Note: may be quit char (fs) 31 | + / beq 2f / yes 2f 32 | cmp r1,$177 / char = "del" ? 33 | beq 2f / yes, 2f 34 | jsr r0,putc; 0 / put char in r1 on clist entry 35 | -------------------------------------------------------------------------------- /patches/core/vec0407.patch: -------------------------------------------------------------------------------- 1 | diff -r -u rebuilt/u0.s build/u0.s 2 | --- rebuilt/u0.s 2008-05-03 08:27:03.000000000 -1000 3 | +++ build/u0.s 2008-05-04 08:25:41.000000000 -1000 4 | @@ -45,9 +45,9 @@ 5 | core = orig+40000 / specifies beginning of user's core 6 | ecore = core+20000 / specifies end of user's core (4096 words) 7 | 8 | -/ 4;4 init by copy 9 | -/ unkni;0 " error 10 | -/ fpsym;0 " illg in tr 11 | + 4;4 / init by copy 12 | + unkni;0 / " error 13 | + fpsym;0 / " illg in tr 14 | unkni;0 / trace and trap (see Sec. B.1 page ) 15 | unkni;0 / trap 16 | panic;0 / pwr 17 | -------------------------------------------------------------------------------- /patches/fixV7div.patch: -------------------------------------------------------------------------------- 1 | diff -ru rebuilt/u0.s build/u0.s 2 | --- rebuilt/u0.s 2008-05-03 08:27:03.000000000 -1000 3 | +++ build/u0.s 2008-05-04 08:28:00.000000000 -1000 4 | @@ -122,7 +122,7 @@ 5 | mov $sb0,(r1)+ / I/O queue entry drum 6 | mov $sb1,(r1)+ / I/O queue entry disk (mounted device) 7 | mov $swp,(r1)+ / I/O queue entry core image being swapped 8 | - mov $[systm-inode]\/2,sb0+4 / sets up initial buffers per 9 | + mov $-109.,sb0+4 / sets up initial buffers per 10 | / format given in 11 | mov $systm,sb0+6 / memory map 12 | mov $-512.,sb1+4 13 | -------------------------------------------------------------------------------- /patches/shell-s2.patch: -------------------------------------------------------------------------------- 1 | --- build/sh.clean 2008-05-11 10:41:44.000000000 -1000 2 | +++ build/sh.s 2008-05-11 10:42:49.000000000 -1000 3 | @@ -142,6 +146,8 @@ 4 | inc r5 / inc r5 to point to return 5 | bic $1,r5 / make it even 6 | clr r0 / set for input 7 | + rts r5 8 | + 9 | sys seek; 0; 2 / exit from runcom. skip to end of 10 | / input file 11 | chcom: / has no effect if tty input 12 | @@ -232,14 +238,6 @@ 13 | sys exec; parbuf; parp / no, execute this commend 14 | sys exec; binpb; parp / or /bin/this command 15 | 2: 16 | - sys stat; binpb; inbuf / if can't execute does it 17 | - / exist? 18 | - bes 2f / branch if it doesn't 19 | - mov $shell,parp-2 / does exist, not executable 20 | - mov $binpb,parp / so it must be 21 | - sys exec; shell; parp-2 / a command file, get it with 22 | - / sh /bin/x (if x name of file) 23 | -2: 24 | jsr r5,error / a return for exec is the diagnostic 25 | ; .even 26 | sys exit 27 | @@ -257,6 +255,8 @@ 28 | beq 1f / yes 29 | cmp r0,$'? / is it ? 30 | beq 3f 31 | + cmp r0,$'* / is it * 32 | + beq 3f 33 | cmp r0,$'[ / is it beginning of character string 34 | / (for glob) 35 | bne 2f 36 | @@ -359,8 +359,6 @@ 37 | 38 | glogin: 39 | 40 | -shell: 41 | - 42 | glob: 43 | 44 | binpb: 45 | -------------------------------------------------------------------------------- /simh.cfg: -------------------------------------------------------------------------------- 1 | #!tools/pdp11 2 | set cpu 11/20 3 | set cpu 32K 4 | set rk0 enabled 5 | att rk0 images/rk0.dsk 6 | set rf 2p 7 | set rf enabled 8 | att rf images/rf0.dsk 9 | set tc enabled 10 | att tc images/tape 11 | set hk disabled 12 | set rha disabled 13 | set tm disabled 14 | set rx disabled 15 | set rl disabled 16 | set tq disabled 17 | set tc enabled 18 | set rf enabled 19 | set ke enabled 20 | set cpu history=1000 21 | set dci en 22 | set dci lines=8 23 | set dco 7b 24 | att dci 5555 25 | load images/m792low.load 26 | dep system sr 173700 27 | go 73700 28 | -------------------------------------------------------------------------------- /src/README.md: -------------------------------------------------------------------------------- 1 | # Source files 2 | 3 | The files in the `c` directory originate from the `last1120c.tar.gz` archive 4 | located at 5 | They constitute a working C compiler for UNIX 2nd Edition. 6 | 7 | The files in the `lib` directory are derived from the `libc.sa` file contained 8 | in the `last1120c.tar.gz` tape image, also available at the same URL. They 9 | constitute the C library for the compiler mentioned above. 10 | 11 | The files in the `cmd` directory have been reconstructed from text fragments 12 | found in the `s1-bits.gz` file, accessible at . 13 | Doug Merritt and Warren Toomey undertook the reconstruction, creating the source 14 | code for some of the commands in UNIX 2nd Edition. 15 | 16 | -------------------------------------------------------------------------------- /src/c/README.md: -------------------------------------------------------------------------------- 1 | # Early C compiler 2 | 3 | This directory contains the last1120c C compiler, as described by Dennis Ritchie 4 | on his web page: . 5 | 6 | You can use the Apout emulator and the C compiler from the s2 tape to recompile 7 | the last1120c compiler. After installing the new compiler binaries, last1120c 8 | can recompile itself. 9 | 10 | Here are the instructions: 11 | 1. First, compile and install the Apout emulator. Ensure that you have enabled 12 | `-DEMUV1` in the Makefile. 13 | 2. Unpack the V1 executables from the s2 tape into a suitable area, e.g., 14 | `/usr/local/src/V1`. Set the environment variable `APOUT_ROOT` to this 15 | directory. 16 | 3. Change to the `last1120c` directory and edit the shell script mak so that it 17 | reflects the `APOUT_ROOT` value you have chosen. Then, simply run the mak 18 | shell script natively. This process will build the front-end command, cc, 19 | and the two passes of the C compiler: c0 and c1. 20 | 4. If desired, you can now move c0 and c1 into `$APOUT_ROOT/usr/lib`, replacing 21 | the original c0 and c1. Then use the shell script mak again to rebuild c0 and 22 | c1 using themselves. Similarly, you can replace `$APOUT_ROOT/bin/cc` with the 23 | cc created here. 24 | 25 | The C compiler can now mostly rebuild itself on the V1 kernel, except for the 26 | c1 pass, which does not work yet. The `v1mak` shell script can be run on V1 to 27 | rebuild everything from source. 28 | -------------------------------------------------------------------------------- /src/c/cctab.s: -------------------------------------------------------------------------------- 1 | / c code tables-- set condition codes 2 | 3 | .globl _cctab 4 | 5 | _cctab=.;.+2 6 | 20.; rest 7 | 21.; rest 8 | 22.; rest 9 | 30.; rest 10 | 31.; rest 11 | 34.; rest 12 | 35.; rest 13 | 36.; rest 14 | 37.; rest 15 | 40.; rest 16 | 41.; rest 17 | 42.; rest 18 | 43.; rest 19 | 44.; rest 20 | 45.; rest 21 | 46.; rest 22 | 47.; rest 23 | 48.; rest 24 | 60.; cc60 25 | 61.; cc60 26 | 62.; cc60 27 | 63.; cc60 28 | 64.; cc60 29 | 65.; cc60 30 | 66.; cc60 31 | 67.; cc60 32 | 68.; cc60 33 | 69.; cc60 34 | 70.; rest 35 | 71.; rest 36 | 72.; rest 37 | 73.; rest 38 | 74.; rest 39 | 75.; rest 40 | 76.; rest 41 | 77.; rest 42 | 78.; rest 43 | 79.; rest 44 | 80.; rest 45 | 46 | / relationals 47 | cc60: 48 | %a,z 49 | tstB1 A1 50 | 51 | %n*,z 52 | F* 53 | tstB1 #1(R) 54 | 55 | %n,z 56 | F 57 | tst R 58 | 59 | %a,a 60 | cmpBE A1,A2 61 | 62 | %n*,a 63 | F* 64 | cmpBE #1(R),A2 65 | 66 | %n,a 67 | F 68 | cmpB2 R,A2 69 | 70 | %n*,e* 71 | F* 72 | S1* 73 | cmpBE #1(R),#2(R1) 74 | 75 | %n*,e 76 | F* 77 | S1 78 | cmpB1 #1(R),R1 79 | 80 | %n,e* 81 | F 82 | S1* 83 | cmpB2 R,#2(R1) 84 | 85 | %n,e 86 | F 87 | S1 88 | cmp R,R1 89 | 90 | %n*,n* 91 | FS* 92 | S* 93 | cmpBE (sp)+,#2(R) 94 | 95 | %n*,n 96 | FS* 97 | S 98 | cmpB1 *(sp)+,R 99 | 100 | %n,n* 101 | FS 102 | S* 103 | cmpB2 (sp)+,#2(R) 104 | 105 | %n,n 106 | FS 107 | S 108 | cmp (sp)+,R 109 | 110 | / set codes right 111 | rest: 112 | %n,n 113 | H 114 | 115 | .data 116 | .even 117 | .text 118 | 119 | -------------------------------------------------------------------------------- /src/c/mak: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Change that value of APOUT_ROOT below to 4 | # match the location where you unpacked 5 | # the 2nd Edition UNIX binaries 6 | # 7 | APOUT_ROOT=/usr/local/src/V1 8 | export APOUT_ROOT 9 | # 10 | cc="apout $APOUT_ROOT/bin/cc" 11 | as="apout $APOUT_ROOT/bin/as" 12 | cvopt="apout cvopt" 13 | rm -f *.o a.out z c0 c1 cvopt 14 | # 15 | echo Building c00; $cc -c c00.c 16 | echo Building c01; $cc -c c01.c 17 | echo Building c02; $cc -c c02.c 18 | echo Building c03; $cc -c c03.c 19 | echo Building c0t; $as c0t.s; mv a.out c0t.o 20 | echo Building c0; $cc c0*.o; mv a.out c0; chmod 755 c0 21 | echo 22 | echo Right, thats c0 done 23 | echo 24 | echo Building c10; $cc -c c10.c 25 | echo Building c11; $cc -c c11.c 26 | echo Building c1t; $as c1t.s; mv a.out c1t.o 27 | echo Building cvopt; $cc cvopt.c; mv a.out cvopt; chmod 755 cvopt 28 | echo Building cctab; $cvopt < cctab.s > z; $as z; mv a.out cctab.o 29 | echo Building efftab; $cvopt < efftab.s > z; $as z; mv a.out efftab.o 30 | echo Building regtab; $cvopt < regtab.s > z; $as z; mv a.out regtab.o 31 | echo Building sptab; $cvopt < sptab.s > z; $as z; mv a.out sptab.o 32 | echo Building c1; $cc c1*.o regtab.o efftab.o cctab.o sptab.o 33 | mv a.out c1; chmod 755 c1 34 | echo 35 | echo Right, thats c1 done 36 | echo 37 | echo Building cc; $cc cc.c; mv a.out cc; chmod 755 cc 38 | rm -f *.o a.out z 39 | -------------------------------------------------------------------------------- /src/c/v1mak: -------------------------------------------------------------------------------- 1 | echo Removing cruft from previous build, ignore errors 2 | rm *.o a.out z c0 c1 cvopt 3 | 4 | echo Building c00; cc -c c00.c 5 | echo Building c01; cc -c c01.c 6 | echo Building c02; cc -c c02.c 7 | echo Building c03; cc -c c03.c 8 | echo Building c0t; as c0t.s; mv a.out c0t.o 9 | echo Building c0; cc c0*.o; mv a.out c0; chmod 022 c0 10 | echo 11 | echo Right, thats c0 done 12 | echo 13 | 14 | echo Building c10; cc -c c10.c 15 | echo Building c11; cc -c c11.c 16 | echo Building c1t; as c1t.s; mv a.out c1t.o 17 | echo Building cvopt; cc cvopt.c; mv a.out cvopt; chmod 022 cvopt 18 | echo Building cctab; ./cvopt z; as z; mv a.out cctab.o 19 | echo Building efftab; ./cvopt z; as z; mv a.out efftab.o 20 | echo Building regtab; ./cvopt z; as z; mv a.out regtab.o 21 | echo Building sptab; ./cvopt z; as z; mv a.out sptab.o 22 | echo Building c1; cc c1*.o regtab.o efftab.o cctab.o sptab.o 23 | mv a.out c1; chmod 022 c1 24 | echo 25 | echo Right, thats c1 done 26 | echo 27 | 28 | echo Building cc; cc cc.c; mv a.out cc; chmod 022 cc 29 | rm *.o z 30 | -------------------------------------------------------------------------------- /src/cmd/as11.s: -------------------------------------------------------------------------------- 1 | / a1 -- pdp-11 assembler pass 1 2 | 3 | 4 | main: 5 | ecore = main+8192. 6 | jmp start 7 | go: 8 | jsr pc,assem 9 | movb pof,r0 10 | sys write; outbuf; 512. 11 | movb pof,r0 12 | sys close 13 | movb fbfil,r0 14 | sys close 15 | tstb errflg 16 | bne aexit 17 | jsr r5,fcreat; a.tmp3 18 | mov $txtsiz,r1 / even up 19 | inc (r1) 20 | bic $1,(r1)+ 21 | inc (r1) 22 | bic $1,(r1)+ 23 | inc (r1) 24 | bic $1,(r1)+ 25 | mov r0,r1 26 | sys write; txtsiz; 6 27 | mov symend,0f 28 | sub $usymtab,0f 29 | mov r1,r0 30 | sys write; usymtab; 0:.. 31 | mov r1,r0 32 | sys close 33 | sys exec; 2f; 1f 34 | 35 | aexit: 36 | sys unlink; a.tmp1 37 | sys unlink; a.tmp2 38 | sys unlink; a.tmp3 39 | sys exit 40 | 1: 41 | 2f 42 | a.tmp1 43 | a.tmp2 44 | a.tmp3 45 | unglob: 46 | 3f 47 | 0 48 | 2: 49 | 50 | 3: 51 | <-g\0> 52 | .even 53 | 54 | filerr: 55 | mov r4,-(sp) 56 | mov (r5)+,r4 57 | mov r4,0f 58 | clr r0 59 | 1: 60 | tstb (r4)+ 61 | beq 1f 62 | inc r0 63 | br 1b 64 | 1: 65 | mov r0,1f 66 | mov $1,r0 67 | sys write; 0:0; 1:0 68 | mov r5,0f 69 | mov $1,r0 70 | sys write; 0:0; 2 71 | tst (r5)+ 72 | mov (sp)+,r4 73 | rts r5 74 | 75 | fcreat: 76 | mov r4,-(sp) 77 | mov (r5)+,r4 78 | mov r4,0f 79 | 1: 80 | sys creat; 0:..; 12 81 | bes 2f 82 | mov (sp)+,r4 83 | rts r5 84 | 2: 85 | incb 9.(r4) 86 | cmpb 9.(r4),$'z 87 | blos 1b 88 | mov 0b,0f 89 | jsr r5,filerr; 0:..; "?\n 90 | sys exit 91 | -------------------------------------------------------------------------------- /src/cmd/as12.s: -------------------------------------------------------------------------------- 1 | / a2 -- pdp-11 assembler pass 1 2 | 3 | error: 4 | incb errflg 5 | mov r0,-(sp) 6 | mov r1,-(sp) 7 | mov (r5)+,r0 8 | mov *curarg,0f 9 | beq 1f 10 | clr *curarg 11 | mov r0,-(sp) 12 | jsr r5,filerr; 0:0; '\n 13 | mov (sp)+,r0 14 | 1: 15 | mov r2,-(sp) 16 | mov r3,-(sp) 17 | mov line,r3 18 | movb r0,1f 19 | mov $1f+6,r0 20 | mov $4,r1 21 | 2: 22 | clr r2 23 | dvd $10.,r2 24 | add $'0,r3 25 | movb r3,-(r0) 26 | mov r2,r3 27 | sob r1,2b 28 | mov $1,r0 29 | sys write; 1f; 7 30 | mov (sp)+,r3 31 | mov (sp)+,r2 32 | mov (sp)+,r1 33 | mov (sp)+,r0 34 | rts r5 35 | 36 | 1: 37 | .even 38 | 39 | betwen: 40 | cmp r0,(r5)+ 41 | blt 1f 42 | cmp (r5)+,r0 43 | blt 2f 44 | 1: 45 | tst (r5)+ 46 | 2: 47 | rts r5 48 | 49 | putw: 50 | tst ifflg 51 | beq 1f 52 | cmp r4,$'\n 53 | bne 2f 54 | 1: 55 | jsr pc,putc1 56 | swab r4 57 | jsr pc,putc1 58 | swab r4 59 | 2: 60 | rts pc 61 | 62 | putc: 63 | tst ifflg 64 | bne 1f 65 | putc1: 66 | movb r4,*obufp 67 | inc obufp 68 | cmp obufp,$outbuf+512. 69 | blo 1f 70 | mov $outbuf,obufp 71 | movb pof,r0 72 | sys write; outbuf; 512. 73 | 1: 74 | rts pc 75 | 76 | -------------------------------------------------------------------------------- /src/cmd/as18.s: -------------------------------------------------------------------------------- 1 | / a8 -- pdp-11 assembler pass 1 2 | 3 | chartab: 4 | .byte -14,-14,-14,-14,-02,-14,-14,-14 5 | .byte -14,-22, -2,-14,-14,-22,-14,-14 6 | .byte -14,-14,-14,-14,-14,-14,-14,-14 7 | .byte -14,-14,-14,-14,-14,-14,-14,-14 8 | .byte -22,-20,-16,-14,-20,-20,-20,-12 9 | .byte -20,-20,-20,-20,-20,-20,38.,-06 10 | .byte 27.,28.,29.,30.,31.,32.,33.,34. 11 | .byte 35.,36.,-20,-02,-00,-20,-14,-14 12 | .byte -14,01.,02.,03.,04.,05.,06.,07. 13 | .byte 08.,09.,10.,11.,12.,13.,14.,15. 14 | .byte 16.,17.,18.,19.,20.,21.,22.,23. 15 | .byte 24.,25.,26.,-20,-24,-20,-20,37. 16 | .byte -14,01.,02.,03.,04.,05.,06.,07. 17 | .byte 08.,09.,10.,11.,12.,13.,14.,15. 18 | .byte 16.,17.,18.,19.,20.,21.,22.,23. 19 | .byte 24.,25.,26.,-14,-26,-14,-14,-14 20 | 21 | errflg: .byte 0 22 | namedone: .byte 0 23 | ch: .byte 0 24 | a.tmp1: 25 | a.tmp2: 26 | a.tmp3: 27 | qi: 28 | .even 29 | 30 | curfb: 31 | -1;-1;-1;-1;-1;-1;-1;-1;-1;-1 32 | obufp: outbuf 33 | symend: usymtab 34 | txtsiz: .=.+2 35 | datsiz: .=.+2 36 | bsssiz: .=.+2 37 | curfbr: .=.+10. 38 | savdot: .=.+6 39 | bufcnt: .=.+2 40 | hshsiz = 1000. 41 | hshtab: .=2*hshsiz+. 42 | pof: .=.+1 43 | wordf: .=.+1 44 | fin: .=.+1 45 | fbfil: .=.+1 46 | fileflg: .=.+1 47 | .even 48 | symbol: .=.+6 49 | inbuf: .=.+512. 50 | obufc: .=.+2 51 | outbuf: .=.+512. 52 | line: .=.+2 53 | inbfcnt: .=.+2 54 | ifflg: .=.+2 55 | inbfp: .=.+2 56 | nargs: .=.+2 57 | curarg: .=.+2 58 | opfound: .=.+2 59 | savop: .=.+2 60 | numval: .=.+2 61 | nxtfb: .=.+4 62 | -------------------------------------------------------------------------------- /src/cmd/as23.s: -------------------------------------------------------------------------------- 1 | / a3 -- pdp-11 assembler pass 2 2 | 3 | assem: 4 | jsr pc,readop 5 | jsr pc,checkeos 6 | br ealoop 7 | mov r4,-(sp) 8 | jsr pc,readop 9 | cmp (sp),$1 10 | bne 1f 11 | mov $2,(sp) 12 | mov r4,numval 13 | jsr pc,readop 14 | 1: 15 | cmp r4,$'= 16 | beq 4f 17 | cmp r4,$': 18 | beq 1f 19 | mov r4,savop 20 | mov (sp)+,r4 21 | jsr pc,opline 22 | br ealoop 23 | 1: 24 | mov (sp)+,r4 25 | cmp r4,$200 26 | bhis 1f 27 | cmp r4,$2 28 | beq 3f 29 | jsr r5,error; 'x 30 | br assem 31 | 1: 32 | cmp dot,symtab+2(r4) 33 | beq assem 34 | jsr r5,error; 'p 35 | br assem 36 | 3: 37 | mov numval,r4 38 | jsr pc,fbadv 39 | br assem 40 | 4: 41 | jsr pc,readop 42 | jsr pc,expres 43 | mov (sp)+,r1 44 | cmp r1,$200 /test for dot 45 | bne 1f 46 | bic $40,r3 47 | cmp r3,dot-2 / can't change relocation 48 | bne 2f 49 | cmp r3,$4 / bss 50 | bne 3f 51 | mov r2,dot 52 | br ealoop 53 | 3: 54 | sub dot,r2 55 | bmi 2f 56 | mov r2,-(sp) 57 | 3: 58 | dec (sp) 59 | bmi 3f 60 | clr r2 61 | mov $1,r3 62 | jsr pc,outb 63 | br 3b 64 | 3: 65 | tst (sp)+ 66 | br ealoop 67 | 2: 68 | jsr r5,error; '. 69 | br ealoop 70 | 1: 71 | cmp r3,$40 72 | bne 1f 73 | jsr r5,error; 'r 74 | 1: 75 | bic $37,symtab(r1) 76 | bic $!37,r3 77 | bne 1f 78 | clr r2 79 | 1: 80 | bisb r3,symtab(r1) 81 | mov r2,symtab+2(r1) 82 | 83 | ealoop: 84 | cmp r4,$'\n 85 | beq 1f 86 | cmp r4,$'\e 87 | bne assem 88 | rts pc 89 | 1: 90 | inc line 91 | br assem 92 | 93 | checkeos: 94 | cmp r4,$'\n 95 | beq 1f 96 | cmp r4,$'; 97 | beq 1f 98 | cmp r4,$'\e 99 | beq 1f 100 | add $2,(sp) 101 | 1: 102 | rts pc 103 | 104 | fbadv: 105 | movb nxtfbr(r4),curfbr(r4) 106 | asl r4 107 | mov nxtfb(r4),curfb(r4) 108 | mov nxtfbp(r4),r1 109 | bne 1f 110 | mov fbbufp,r1 111 | 1: 112 | cmpb r4,(r1)+ 113 | beq 1f 114 | tstb (r1)+ 115 | bpl 2f 116 | dec r1 117 | br 1f 118 | 2: 119 | tst (r1)+ 120 | br 1b 121 | 1: 122 | movb (r1)+,r0 123 | mov (r1)+,nxtfb(r4) 124 | mov r1,nxtfbp(r4) 125 | asr r4 126 | movb r0,nxtfbr(r4) 127 | rts pc 128 | 129 | -------------------------------------------------------------------------------- /src/cmd/as25.s: -------------------------------------------------------------------------------- 1 | / as25 is empty 2 | -------------------------------------------------------------------------------- /src/cmd/as28.s: -------------------------------------------------------------------------------- 1 | / as8 -- PDP-11 assembler pass 2 2 | 3 | chartab: 4 | <\0abcdefg> 5 | 6 | 7 | 8 | <6789_.> 9 | 10 | qnl: 11 | qii: 12 | 13 | a.out: 14 | badfil: / a file which should never exist 15 | 16 | .even 17 | a.outp: a.out 18 | a.tmp1: badfil 19 | a.tmp2: badfil 20 | a.tmp3: badfil 21 | 22 | tseekp: txtseek 23 | rseekp: trelseek 24 | 25 | txtmagic: 26 | br .+20 27 | txtsiz: .=.+2 28 | datsiz: .=.+2 29 | bsssiz: .=.+2 30 | symsiz: .=.+2 31 | stksiz: .=.+2 32 | exorig: .=.+2 33 | .=.+2 34 | 35 | txtseek: 20 36 | datseek: .=.+2 37 | .=.+2 38 | trelseek: .=.+2 39 | drelseek: .=.+2 40 | .=.+2 41 | symseek: .=.+2 42 | 43 | fbbufp: .=.+2 44 | defund: .=.+2 45 | savdot: .=.+6 46 | datbase: .=.+2 47 | bssbase: .=.+2 48 | fbfil: .=.+2 49 | fin: .=.+2 50 | ibufc: .=.+2 51 | txtfil: .=.+2 52 | symf: .=.+2 53 | adrbuf: .=.+12. 54 | xsymbol: .=.+2 55 | fout: .=.+2 56 | ch: .=.+2 57 | wordf: .=.+2 58 | argb: .=.+22. 59 | line: .=.+2 60 | savop: .=.+2 61 | curfb: .=.+20. 62 | nxtfb: .=.+20. 63 | nxtfbp: .=.+20. 64 | curfbr: .=.+10. 65 | nxtfbr: .=.+10. 66 | numval: .=.+2 67 | maxtyp: .=.+2 68 | relfil: .=.+2 69 | ibufp: .=.+2 70 | inbuf: .=.+512. 71 | txtp: .=.+6+512. 72 | relp: .=.+6+512. 73 | swapf: .=.+2 74 | rlimit: .=.+2 75 | -------------------------------------------------------------------------------- /src/cmd/cat.s: -------------------------------------------------------------------------------- 1 | / cat -- concatinate files 2 | 3 | mov (sp)+,r5 4 | tst (sp)+ 5 | mov $obuf,r2 6 | cmp r5,$1 7 | beq 3f 8 | 9 | loop: 10 | dec r5 11 | ble done 12 | mov (sp)+,r0 13 | cmpb (r0),$'- 14 | bne 2f 15 | clr fin 16 | br 3f 17 | 2: 18 | mov r0,0f 19 | sys open; 0:..; 0 20 | bes loop 21 | mov r0,fin 22 | 3: 23 | mov fin,r0 24 | sys read; ibuf; 512. 25 | bes 3f 26 | mov r0,r4 27 | beq 3f 28 | mov $ibuf,r3 29 | 4: 30 | movb (r3)+,r0 31 | jsr pc,putc 32 | dec r4 33 | bne 4b 34 | br 3b 35 | 3: 36 | mov fin,r0 37 | beq loop 38 | sys close 39 | br loop 40 | 41 | done: 42 | sub $obuf,r2 43 | beq 1f 44 | mov r2,0f 45 | mov $1,r0 46 | sys write; obuf; 0:.. 47 | 1: 48 | sys exit 49 | 50 | putc: 51 | movb r0,(r2)+ 52 | cmp r2,$obuf+512. 53 | blo 1f 54 | mov $1,r0 55 | sys write; obuf; 512. 56 | mov $obuf,r2 57 | 1: 58 | rts pc 59 | 60 | .bss 61 | ibuf: .=.+512. 62 | obuf: .=.+512. 63 | fin: .=.+2 64 | .text 65 | 66 | -------------------------------------------------------------------------------- /src/cmd/chmod.s: -------------------------------------------------------------------------------- 1 | / chmod - change mode 2 | 3 | chmode: 4 | mov sp,r5 5 | mov (r5),r4 6 | cmp r4,$3 7 | blt chmerr 8 | add $4,r5 9 | mov (r5)+,r1 10 | clr 0f 11 | 1: 12 | movb (r1)+,r0 13 | beq 1f 14 | asl 0f 15 | asl 0f 16 | asl 0f 17 | bic $!7,r0 18 | bis r0,0f 19 | br 1b 20 | 1: 21 | mov (r5)+,0f-2 22 | sys chmod; ..; 0:.. 23 | bes chmerr 24 | dec r4 25 | cmp r4,$3 26 | bge 1b 27 | sys exit 28 | 29 | chmerr: 30 | mov $1,r0 31 | sys write; 1f; 2 32 | sys exit 33 | 34 | 1: 35 | -------------------------------------------------------------------------------- /src/cmd/chown.s: -------------------------------------------------------------------------------- 1 | / chown -- change owner 2 | 3 | 4 | .globl fopen, getc, mesg 5 | 6 | mov sp,r5 7 | mov (r5),r4 8 | cmp r4,$3 9 | bge 1f 10 | jsr r5,mesg; ; .even 11 | 1: 12 | add $4,r5 13 | mov (r5),r3 14 | cmpb (r3),$'0 15 | blt 1f 16 | cmpb (r3),$'9 17 | bgt 1f 18 | jsr r5,cvnum; geta 19 | br do 20 | 1: 21 | mov $uids,r0 22 | jsr r5,fopen; ubuf 23 | bec 1f 24 | jsr r5,mesg; ; .even 25 | sys exit 26 | 1: 27 | mov r3,r2 28 | 2: 29 | jsr r5,getc; ubuf 30 | bcc 3f 31 | who: 32 | jsr r5,mesg; ; .even 33 | sys exit 34 | 3: 35 | cmp r0,$': 36 | beq 3f 37 | cmpb (r2)+,r0 38 | beq 2b 39 | 2: 40 | jsr r5,getc; ubuf 41 | bcs who 42 | cmp r0,$'\n 43 | bne 2b 44 | br 1b 45 | 3: 46 | tstb (r2) 47 | bne 2b 48 | 3: 49 | jsr r5,getc; ubuf 50 | cmpb r0,$': 51 | bne 3b 52 | jsr r5,cvnum; getc 53 | do: 54 | sub $2,r4 55 | mov r1,0f+2 56 | tst (r5)+ 57 | 1: 58 | mov (r5)+,0f 59 | sys chown; 0:..; 0 60 | bec 2f 61 | mov 0b,r0 62 | mov r0,0f 63 | clr 0f+2 64 | 3: 65 | tstb (r0)+ 66 | beq 3f 67 | inc 0f+2 68 | br 3b 69 | 3: 70 | mov $1,r0 71 | sys write; 0:..; .. 72 | jsr r5,mesg; ; .even 73 | 2: 74 | dec r4 75 | bgt 1b 76 | sys exit 77 | 78 | cvnum: 79 | clr r1 80 | 1: 81 | jsr r5,*(r5); ubuf 82 | bcs 1f 83 | sub $'0,r0 84 | cmp r0,$9. 85 | bhi 1f 86 | mpy $10.,r1 87 | add r0,r1 88 | br 1b 89 | 1: 90 | tst (r5)+ 91 | rts r5 92 | 93 | geta: 94 | movb (r3)+,r0 95 | tst (r5)+ 96 | rts r5 97 | 98 | uids: 99 | 100 | .bss 101 | ubuf: .=.+518. 102 | -------------------------------------------------------------------------------- /src/cmd/cmp.s: -------------------------------------------------------------------------------- 1 | / cmp -- compare files 2 | 3 | 4 | cmp (sp)+,$3 5 | beq 1f 6 | jsr r5,mesg; ; .even 7 | sys exit 8 | 1: 9 | tst (sp)+ 10 | mov (sp)+,0f 11 | sys open; 0:..; 0 12 | bec 1f 13 | jsr r5,mesg; ; .even 14 | sys exit 15 | 1: 16 | mov r0,f1 17 | mov (sp)+,0f 18 | sys open; 0:..; 0 19 | bec 1f 20 | jsr r5,mesg; ; .even 21 | sys exit 22 | 1: 23 | mov r0,f2 24 | clr r2 25 | 1: 26 | jsr r5,getw; f1 27 | bvs eof1 28 | mov r0,r3 29 | jsr r5,getw; f2 30 | bvs eof2 31 | cmp r0,r3 32 | beq 2f 33 | mov r0,r4 34 | mov r2,r0 35 | jsr pc,octal 36 | jsr r5,mesg; <: \0>; .even 37 | mov r3,r0 38 | jsr pc,octal 39 | jsr r5,mesg; < \0>; 40 | mov r4,r0 41 | jsr pc,octal 42 | jsr r5,mesg; <\n\0> 43 | 2: 44 | add $2,r2 45 | br 1b 46 | eof1: 47 | jsr r5,getw; f2 48 | bvs 1f 49 | jsr r5,mesg; ; .even 50 | sys exit 51 | 1: 52 | sys exit 53 | 54 | eof2: 55 | jsr r5,mesg; ; .even 56 | sys exit 57 | 58 | mesg: 59 | movb (r5)+,ch 60 | beq 1f 61 | mov $1,r0 62 | sys write; ch; 1 63 | br mesg 64 | 1: 65 | inc r5 66 | bic $1,r5 67 | rts r5 68 | 69 | getw: 70 | mov (r5)+,r1 71 | cmp 2(r1),$1 72 | bne 1f 73 | mov *4(r1),r0 74 | bic $!377,r0 75 | dec 2(r1) 76 | rts r5 77 | 1: 78 | sub $2,2(r1) 79 | bge 1f 80 | mov (r1),r0 81 | mov r1,0f 82 | add $6,0f 83 | sys read; 0:..; 512. 84 | mov r0,2(r1) 85 | bne 2f 86 | sev 87 | rts r5 88 | 2: 89 | mov r1,4(r1) 90 | add $6,4(r1) 91 | sub $2,2(r1) 92 | 1: 93 | mov *4(r1),r0 94 | add $2,4(r1) 95 | rts r5 96 | 97 | octal: 98 | mov r4,-(sp) 99 | mov r0,r5 100 | mov $6,-(sp) 101 | 1: 102 | clr r4 103 | alsc $1,r4 104 | cmp (sp),$6 105 | beq 2f 106 | alsc $2,r4 107 | 2: 108 | add $'0,r4 109 | mov r4,ch 110 | mov $1,r0 111 | sys write; ch; 1 112 | dec (sp) 113 | bne 1b 114 | tst (sp)+ 115 | mov (sp)+,r4 116 | rts pc 117 | 118 | .bss 119 | 120 | ch: .=.+2 121 | f1: .=.+6; .=.+512. 122 | f2: .=.+6; .=.+512. 123 | -------------------------------------------------------------------------------- /src/cmd/colon.s: -------------------------------------------------------------------------------- 1 | / colon -- do nothing 2 | 3 | sys exit 4 | 5 | -------------------------------------------------------------------------------- /src/cmd/cp.c: -------------------------------------------------------------------------------- 1 | main(argc,argv) 2 | char **argv; 3 | { 4 | char buf[512]; 5 | int fold, fnew, n; 6 | char *p1, *p2, *bp; 7 | int mode; 8 | if(argc != 3) { 9 | write(1,"Usage: cp oldfile newfile\n",26); 10 | exit(); 11 | } 12 | if((fold = open(argv[1],0)) < 0){ 13 | write(1,"Cannot open old file.\n",22); 14 | exit(); 15 | } 16 | fstat(fold,buf); 17 | mode = buf[2] & 037; 18 | if((fnew = creat(argv[2],mode)) < 0){ 19 | stat(argv[2], buf); 20 | if((buf[3] & 0100) != 0){ 21 | p1 = argv[1] - 1; 22 | p2 = argv[2] - 1; 23 | bp = buf - 1; 24 | while(*++bp = *++p2); 25 | *bp = '/'; 26 | p2 = bp; 27 | while(*++bp = *++p1) 28 | if(*bp == '/') 29 | bp = p2; 30 | if((fnew = creat(buf,mode)) < 0){ 31 | write(1,"Cannot creat new file.\n",23); 32 | exit(); 33 | } 34 | }else{ 35 | write(1,"Cannot creat new file.\n",23); 36 | exit(); 37 | } 38 | } 39 | while(n = read(fold, buf, 512)) 40 | if(n < 0){ 41 | write(1,"Read error\n",11); 42 | exit(); 43 | }else 44 | if(write(fnew,buf,n) != n){ 45 | write(1,"Write error.\n",13); 46 | exit(); 47 | } 48 | fstat(fnew,buf); 49 | exit(); 50 | } 51 | -------------------------------------------------------------------------------- /src/cmd/date.s: -------------------------------------------------------------------------------- 1 | / get date -- date 2 | / set date -- date mmddhhmm 3 | 4 | .globl ptime 5 | 6 | cmp (sp)+,$2 7 | blt prdate 8 | tst (sp)+ 9 | mov (sp),r0 10 | setd 11 | seti 12 | jsr r5,tmul; 0 13 | jsr r5,tmul; 10. 14 | movfi fr1,r1 / months in r2 15 | asl r1 16 | jsr r5,tmul; 0 17 | jsr r5,tmul; 10. 18 | movfi fr1,r3 / days in r3 19 | dec r3 20 | add mtab-2(r1),r3 21 | cmp r1,$6 / march or later? 22 | blt 1f 23 | add yr1972,r3 / leap year correction 24 | 1: 25 | mpy $24.,r3 / days to hours 26 | jsr r5,tmul; 0 27 | jsr r5,tmul; 10. 28 | movif r3,fr0 29 | addf fr0,fr1 / total hours 30 | jsr r5,tmul; 6. 31 | jsr r5,tmul; 10. 32 | movif $3600.,fr0 33 | mulf fr0,fr1 34 | tstb (r0) 35 | bne error 36 | setl 37 | tst yr1972 38 | beq 1f 39 | movif yrtime,fr0 40 | addf fr0,fr1 41 | 1: 42 | movif two,fr0 43 | divf fr0,fr1 44 | movfi fr1,-(sp) 45 | mov (sp)+,r0 46 | mov (sp)+,r1 47 | alsc $1,r0 48 | sys stime 49 | br 1f 50 | 51 | prdate: 52 | sys time 53 | 1: 54 | alsc $-8,r0 55 | bic $!377,r0 56 | dvd $20250.,r0 57 | add $0.,r0 58 | mov r0,r1 59 | clr r0 60 | dvd $7.,r0 61 | mpy $5.,r1 62 | add $days,r1 63 | mov r1,0f 64 | mov $1,r0 65 | sys write; 0:..; 5 66 | sys time 67 | mov $1,r2 68 | jsr pc,ptime 69 | mov $1,r0 70 | sys write; nl; 1 71 | sys exit 72 | 73 | error: 74 | mov $1,r0 75 | sys write; 1f; 2 76 | sys exit 77 | 1: 78 | nl: <\n> 79 | 80 | tmul: 81 | movif (r5)+,fr2 82 | mulf fr2,fr1 83 | movb (r0)+,r2 84 | beq error 85 | sub $'0,r2 86 | cmp r2,$10. 87 | bhis error 88 | movif r2,fr2 89 | addf fr2,fr1 90 | rts r5 91 | 92 | yrtime: 93 | 28872.; 4608. 94 | 95 | mtab: 96 | 0 97 | 31. 98 | 59. 99 | 90. 100 | 120. 101 | 151. 102 | 181. 103 | 212. 104 | 243. 105 | 273. 106 | 304. 107 | 334. 108 | 0 109 | 110 | yr1972: 1 111 | two: 0; 2 112 | days: 113 | 114 | 115 | 116 | 117 | 118 | 119 | .even 120 | -------------------------------------------------------------------------------- /src/cmd/db4.s: -------------------------------------------------------------------------------- 1 | / db4 -- debugger 2 | 3 | maxsym = 24000. 4 | core: 5 | 6 | a.out: 7 | 8 | .even 9 | zero: 0 10 | .bss 11 | regbuf: 12 | u.sp: .=.+2 13 | u.usp: .=.+2 14 | u.uusp: .=.+2 15 | u.break:.=.+2 16 | u.r0: .=.+2 17 | u.savps:.=.+2 18 | u.core: .=.+2 19 | .=regbuf+512. 20 | u.pusp: .=.+2 21 | .data 22 | objmagic: br .+20 23 | namsiz: nambuf 24 | incdot: 2 25 | nlcom: '/ 26 | 27 | regnames: 28 | ; 1; 161000 29 | ; 1; 160776 30 | ; 1; 160774 31 | ; 1; 160772 32 | ; 1; 160770 33 | ; 1; 160766 34 | ; 1; 160764 35 | ; 1; 160762 36 | ; 1; 160760 37 | .if fpp 38 | fregnames: 39 | ; 1; 160754 40 | ; 1; 160750 41 | ; 1; 160744 42 | ; 1; 160740 43 | ; 1; 160734 44 | ; 1; 160730 45 | .endif 46 | ereg: 47 | 48 | .bss 49 | 50 | starmod:.=.+2 51 | symbol: .=.+10. 52 | getoff: .=.+2 53 | namstrt: .=.+2 54 | bytemod: .=.+2 55 | savsp: .=.+2 56 | error: .=.+2 57 | ttyfin: .=.+2 58 | dbfin: .=.+2 59 | dbfout: .=.+2 60 | ch: .=.+2 61 | lastop: .=.+2 62 | addres: .=.+2 63 | taddr: .=.+2 64 | adrflg: .=.+2 65 | f.size: .=.+2 66 | fpsr: .=.+2 67 | och: .=.+2 68 | dot: .=.+2 69 | count: .=.+2 70 | syscnt: .=.+2 71 | temp: .=.+2 72 | temp1: .=.+2 73 | obuf: .=.+8. 74 | ecore = db+8192. 75 | inbuf: .=.+128. 76 | nambuf: .=.+20 77 | 78 | -------------------------------------------------------------------------------- /src/cmd/df.s: -------------------------------------------------------------------------------- 1 | / df -- find free space 2 | 3 | cmp (sp)+,$1 4 | bgt 1f 5 | mov $rf0,0f 6 | jsr pc,df 7 | mov $1,r0 8 | sys write; plus; 1 9 | mov $rk1,0f 10 | jsr pc,df 11 | mov $1,r0 12 | sys write; plus; 1 13 | mov $rk2,0f 14 | jsr pc,df 15 | mov $1,r0 16 | sys write; plus; 1 17 | mov $rk3,0f 18 | jsr pc,df 19 | mov $1,r0 20 | 2: 21 | mov $1,r0 22 | sys write; nl; 1 23 | sys exit 24 | 25 | 1: 26 | tst (sp)+ 27 | mov (sp)+,0f 28 | jsr pc,df 29 | br 2b 30 | 31 | df: 32 | clr r3 33 | sys 36. 34 | sys open; 0:..; 0 35 | bes 9f 36 | sys read; nfree; 1024. 37 | mov $freeb,r1 38 | mov nfree,r2 39 | asr r2 40 | 1: 41 | mov $16.,r4 42 | mov (r1)+,r5 43 | 2: 44 | rol r5 45 | adc r3 46 | dec r4 47 | bne 2b 48 | dec r2 49 | bgt 1b 50 | 9: 51 | clr r2 52 | dvd $10.,r2 53 | mov r3,-(sp) 54 | mov r2,r3 55 | beq 2f 56 | jsr pc,9b 57 | 2: 58 | movb (sp)+,ch 59 | add $'0,ch 60 | mov $1,r0 61 | sys write; ch; 1 62 | rts pc 63 | 64 | rf0: 65 | rk0: 66 | rk1: 67 | rk2: 68 | rk3: 69 | plus: <+> 70 | nl: <\n> 71 | .even 72 | 73 | .bss 74 | ch: .=.+2 75 | nfree: .=.+2 76 | freeb: .=.+1022. 77 | -------------------------------------------------------------------------------- /src/cmd/dsw.s: -------------------------------------------------------------------------------- 1 | / dsw - delete from tty 2 | 3 | cmp (sp)+,$2 4 | blt 1f 5 | tst (sp)+ 6 | mov (sp)+,0f 7 | 1: 8 | sys stat; 0:dot; stbuf 9 | bes error 10 | bit $40000,stbuf+2 11 | beq error 12 | mov 0b,0f 13 | sys open; 0:..; 0 14 | bes error 15 | mov r0,r1 16 | 1: 17 | clrb buf+10. 18 | mov r1,r0 19 | sys read; buf; 10. 20 | bes done 21 | tst r0 22 | beq done 23 | tst buf 24 | beq 1b 25 | mov 0b,r2 26 | mov $obuf,r3 27 | 2: 28 | movb (r2)+,(r3)+ 29 | bne 2b 30 | mov $buf+2,r2 31 | dec r3 32 | cmpb -1(r3),$'/ 33 | beq 2f 34 | movb $'/,(r3)+ 35 | 2: 36 | movb (r2)+,(r3)+ 37 | bne 2b 38 | sys stat; obuf; stbuf 39 | bes error 40 | bit $40000,stbuf+2 41 | bne 1b 42 | mov $buf+2,r2 43 | 2: 44 | tstb (r2)+ 45 | bne 2b 46 | movb $' ,-(r2) 47 | sub $buf+1,r2 48 | mov r2,0f 49 | 50 | 2: 51 | mov $1,r0 52 | sys write; buf+2; 0:.. 53 | clr r0 54 | sys read; ch; 1 55 | cmpb ch,$'\n 56 | beq 1b 57 | clr r0 58 | sys read; ch1; 1 59 | cmpb ch1,$'\n 60 | beq 3f 61 | 4: 62 | clr r0 63 | sys read; ch; 1 64 | cmpb ch,$'\n 65 | beq 2b 66 | br 4b 67 | 3: 68 | cmpb ch,$'x 69 | beq done 70 | cmpb ch,$'y 71 | bne 2b 72 | sys unlink; obuf 73 | bes error 74 | br 1b 75 | 76 | done: 77 | sys exit 78 | 79 | error: 80 | mov $1,r0 81 | sys write; mes; 2 82 | sys exit 83 | 84 | dot: <.\0> 85 | mes: 86 | 87 | .bss 88 | obuf: .=.+100. 89 | stbuf: .=.+40. 90 | buf: .=.+11. 91 | ch: .=.+1 92 | ch1: .=.+1 93 | 94 | -------------------------------------------------------------------------------- /src/cmd/exit.c: -------------------------------------------------------------------------------- 1 | /* exit -- end runcom */ 2 | 3 | main() { 4 | seek(0, 0, 2); 5 | } 6 | -------------------------------------------------------------------------------- /src/cmd/fed1.s: -------------------------------------------------------------------------------- 1 | testing = 0 2 | / 3 | / command interpreter for form letter editor 4 | / 5 | / 6 | / 7 | command: 8 | sys intr; inter 9 | jsr pc,initl 10 | mov sp,spi 11 | loop: 12 | mov spi,sp 13 | mov $buffer,r2 14 | clr r4 15 | clr iflag 16 | 1: 17 | jsr pc,tfiget 18 | cmpb $' ,r0 19 | beq 1f 20 | cmpb $'\n,r0 21 | bne 2f 22 | clrb (r2) 23 | br 4f 24 | 2: 25 | movb r0,(r2)+ 26 | br 1b 27 | 1: 28 | clrb (r2) 29 | mov $argc,r3 30 | 3: 31 | mov $arg,r2 32 | 2: 33 | jsr pc,tfiget 34 | cmpb $' ,r0 35 | beq 1f 36 | cmpb $'\n,r0 37 | beq 1f 38 | movb r0,(r2)+ 39 | br 2b 40 | 1: 41 | clrb (r2)+ 42 | inc r4 43 | 1: 44 | movb -(r2),sv 45 | cmp r2,$arg 46 | blos 1f 47 | movb -(r2),-(sp) 48 | movb sv,1(sp) 49 | cmp r2,$arg 50 | bhi 1b 51 | mov sp,(r3)+ 52 | br 2f 53 | 1: 54 | clrb -(sp) 55 | movb sv,1(sp) 56 | mov sp,(r3) 57 | add $1,(r3)+ 58 | 2: 59 | cmpb r0,$'\n 60 | bne 3b 61 | 1: 62 | mov -(r3),-(sp) 63 | cmp r3,$argc 64 | bhi 1b 65 | 4: 66 | mov r4,-(sp) 67 | 3: 68 | clr r0 69 | mov $tabl,r4 70 | 2: 71 | mov (r4)+,r1 72 | cmp r4,$tend 73 | bhi error 74 | add $2,r0 75 | mov $buffer,r2 76 | 1: 77 | cmpb (r1)+,(r2)+ 78 | bne 2b 79 | tstb (r1) 80 | bne 1b 81 | tstb (r2) 82 | bne 2b 83 | sub $2,r0 84 | add $jtable,r0 85 | clr vflag 86 | clr qflag 87 | jmp *(r0) 88 | / 89 | error: 90 | mov $1,r0 91 | sys write; err; 2 92 | br loop 93 | / 94 | / 95 | tabl: c1; c2; c3; c4; c5; c6; c7; c8; 96 | tend: 0 97 | c1: 98 | c2: 99 | c3: 100 | c4: 101 | c5: 102 | c6: 103 | c7: 104 | c8: 105 | err: 106 | endt: .even 107 | jtable: list; listf; ed; remove; rename; fin; q; memck; 108 | spi: .=.+2 109 | sv: .=.+2 110 | -------------------------------------------------------------------------------- /src/cmd/form2.s: -------------------------------------------------------------------------------- 1 | / scan 2 | / r1 = pointer to input header 3 | / r0 = pointer to output header 4 | / switch = 0 real output 5 | / not 0 output to r0 6 | scan: 7 | mov r0,-(sp) 8 | mov r1,-(sp) 9 | 10 | 1: 11 | mov (sp),r1 12 | jsr pc,getchar 13 | bes 5f 14 | cmpb r0,$'\\ 15 | beq 3f 16 | cmpb r0,$'\[ 17 | beq 4f 18 | cmpb r0,$'\{ 19 | beq 4f 20 | cmpb r0,$'\] 21 | beq 1f 22 | cmpb r0,$'\} 23 | beq 7f 24 | cmpb r0,$'\n 25 | bne 6f 26 | jsr pc,lookchar 27 | bes 5f 28 | movb $'\n,r0 29 | 6: 30 | tst switch 31 | beq 2f 32 | mov 2(sp),r1 33 | jsr pc,putchar 34 | br 1b 35 | 2: 36 | jsr r5,putc 37 | br 1b 38 | 3: 39 | jsr pc,getchar 40 | br 6b 41 | / have [ or { 42 | 4: 43 | mov r(r1),-(sp) 44 | jsr pc,getchar 45 | bes 1f 46 | cmpb r0,$'0 47 | blt 4f 48 | cmpb r0,$'9 49 | bgt 4f 50 | jsr pc,getchar 51 | cmpb r0,$'\] 52 | beq 3f 53 | cmpb r0,$'\} 54 | beq 3f 55 | 56 | 4: 57 | mov (sp)+,r(r1) 58 | mov 2(sp),r0 59 | jsr pc,esub 60 | mov r1,(sp) 61 | mov r0,2(sp) 62 | br 1b 63 | 64 | / have arg 65 | 3: 66 | tst switch 67 | beq 2f 68 | mov opointer,r1 69 | mov 4(sp),r0 70 | jsr pc,putword 71 | mov 2(sp),r1 72 | 2: 73 | mov (sp)+,r(r1) 74 | jsr pc,getchar 75 | inc r(r1) /skip ] 76 | jsr pc,earg 77 | br 1b 78 | 79 | 5: 80 | tst argf 81 | bne 1f 82 | mov ipointer,r1 83 | jsr pc,pop 84 | bes 1f 85 | mov r0,(sp) 86 | br 1b 87 | 7: 88 | inc curlyf 89 | 1: 90 | mov (sp)+,r1 91 | mov (sp)+,r0 92 | rts pc 93 | -------------------------------------------------------------------------------- /src/cmd/goto.c: -------------------------------------------------------------------------------- 1 | int offset 0; 2 | 3 | main(argc, argv) 4 | char *argv[]; 5 | { 6 | extern fin; 7 | char line[64]; 8 | 9 | fin = dup(0); 10 | if (!gtty(0, line) | argc<=1) { 11 | write(1, "goto error\n", 11); 12 | seek(0, 0, 2); 13 | return; 14 | } 15 | seek(0, 0, 0); 16 | loop: 17 | if (getlin(line)) { 18 | write(1, "label not found\n", 16); 19 | return; 20 | } 21 | if (compar(line, argv[1])) goto loop; 22 | seek(0, offset, 0); 23 | } 24 | 25 | getlin(s) 26 | char s[]; 27 | { 28 | int ch, i; 29 | 30 | i = 0; 31 | l: 32 | if ((ch=getc())=='\0') return(1); 33 | if (ch!=':') { 34 | while(ch!='\n' & ch!='\0') 35 | ch = getc(); 36 | goto l; 37 | } 38 | while ((ch=getc())==' '); 39 | while (ch!=' ' & ch!='\n' & ch!='\0') { 40 | s[i++] = ch; 41 | ch = getc(); 42 | } 43 | s[i] = '\0'; 44 | return(0); 45 | } 46 | 47 | compar(s1, s2) 48 | char s1[], s2[]; 49 | { 50 | int c, i; 51 | 52 | i = 0; 53 | l: 54 | if(s1[i] != s2[i]) return(1); 55 | if (s1[i++] == '\0') return(0); 56 | goto l; 57 | } 58 | 59 | getc() 60 | { 61 | 62 | offset++; 63 | return(getchar()); 64 | } 65 | -------------------------------------------------------------------------------- /src/cmd/ln.s: -------------------------------------------------------------------------------- 1 | / link command 2 | 3 | ln: 4 | mov sp,r5 5 | cmp (r5)+,$2 6 | bhis 1f 7 | sys exit 8 | 1: 9 | beq 1f 10 | tst (r5)+ 11 | mov (r5)+,0f 12 | mov (r5),0f+2 13 | br 2f 14 | 1: 15 | tst (r5)+ 16 | mov (r5),0f 17 | mov (r5),r4 18 | 1: 19 | tstb (r4)+ 20 | bne 1b 21 | 1: 22 | cmpb -(r4),$'/ 23 | beq 1f 24 | cmp (r5),r4 25 | bne 1b 26 | br err 27 | 1: 28 | inc r4 29 | mov r4,0f+2 30 | 2: 31 | mov 0f,2f 32 | sys stat; 2:..; stbuf 33 | bes err 34 | bit $40000,stbuf+2 35 | bne err 36 | sys link; 0:..; .. 37 | bes err 38 | sys exit 39 | 40 | err: 41 | mov $1,r0 42 | sys write; quest; 2 43 | sys exit 44 | 45 | quest: 46 | 47 | 48 | .bss 49 | stbuf: .=.+40. 50 | -------------------------------------------------------------------------------- /src/cmd/mak: -------------------------------------------------------------------------------- 1 | echo acct.s; as acct.s; mv a.out acct 2 | echo ar.s; as ar.s; mv a.out ar 3 | echo cat.s; as cat.s; mv a.out cat 4 | echo chmod.s; as chmod.s; mv a.out chmod 5 | echo chown.s; as chown.s; mv a.out chown 6 | echo cmp.s; as cmp.s; mv a.out cmp 7 | echo colon.s; as colon.s; mv a.out : 8 | echo date.s; as date.s; mv a.out date 9 | echo df.s; as df.s; mv a.out df 10 | echo dsw.s; as dsw.s; mv a.out dsw 11 | echo dusg.s; as dusg.s; mv a.out dusg 12 | echo fstrip.s; as fstrip.s; mv a.out fstrip 13 | echo getty.s; as getty.s; mv a.out getty 14 | echo init.s; as init.s; mv a.out init 15 | echo ln.s; as ln.s; mv a.out ln 16 | echo login.s; as login.s; mv a.out login 17 | echo ls.s; as ls.s; mv a.out ls 18 | echo sh.s; as sh.s; mv a.out sh 19 | echo db; as db?.s; mv a.out db 20 | echo ld; as ld?.s; mv a.out ld 21 | echo as2; as as2?.s; mv a.out as2 22 | echo as; as as1?.s; mv a.out as 23 | 24 | echo Not bas, missing source files 25 | echo Not dc, uses the mul instruction 26 | echo ... install new "as" to build dc 27 | echo Not fed, uses the div instruction 28 | echo ... also cannot be built using new as 29 | echo Not form, uses the ashc instruction 30 | echo ... install new "as" to build dc 31 | 32 | echo You can rm ':' acct ar cat chmod chown 33 | echo You can rm cmp date df dsw dusg fstrip getty 34 | echo You can rm init ln login ls sh as as2 db ld 35 | -------------------------------------------------------------------------------- /src/cmd/unknown.c: -------------------------------------------------------------------------------- 1 | char b[242]; 2 | char c[60]; 3 | int nread 1; 4 | char buf[512]; 5 | 6 | main(argc,argv) int argc; char *argv[]; { 7 | int l,isw,k,ifile,i,j; 8 | 9 | if(--argc <= 0) 10 | {ifile = 0; 11 | argc = 0; 12 | goto newl; 13 | } 14 | 15 | l = 1; 16 | while(argc--) 17 | {printf("%s:\n \n",argv[l]); 18 | ifile = open(argv[l++],0); 19 | if(ifile < 0) 20 | {printf("cannot open input file\n"); 21 | exit(); 22 | } 23 | newl: 24 | isw = j = 0; 25 | i = -1; 26 | cont: 27 | while((b[++i] = get(ifile)) != 0) 28 | {if((b[i] >= 'a' & b[i] <= 'z') | 29 | (b[i] >= 'A' & b[i] <= 'Z')) 30 | {c[j++] = b[i]; 31 | goto cont; 32 | } 33 | if(b[i] == '-') 34 | {c[j++] = b[i]; 35 | if((b[++i] = get(ifile)) != '\n') 36 | {c[j++] = b[i]; 37 | goto cont; 38 | } 39 | if(j == 1)goto newl; 40 | isw = 1; 41 | i = -1; 42 | while(((b[++i] = get(ifile)) == ' ') 43 | | (b[i] == '\t') | (b[i] == '\n')); 44 | c[j++] = b[i]; 45 | goto cont; 46 | } 47 | if(b[i] == '\n'){if(isw != 1)goto newl; 48 | i = -1; } 49 | if(isw == 1) 50 | {k = 0; 51 | c[j++] = '\n'; 52 | while(k < j)putchar(c[k++]); 53 | } 54 | isw = j = 0; 55 | } 56 | } 57 | } 58 | get(ifile) int ifile;{ 59 | char *ibuf; 60 | static ibuf; 61 | 62 | if(--nread){ 63 | return(*ibuf++);} 64 | 65 | if(nread = read(ifile,buf,512)){ 66 | if(nread < 0)goto err; 67 | 68 | ibuf = buf; 69 | return(*ibuf++); 70 | } 71 | 72 | nread = 1; 73 | return(0); 74 | 75 | err: 76 | nread = 1; 77 | printf("read error\n"); 78 | return(0); 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/lib/chdir.s: -------------------------------------------------------------------------------- 1 | / C library -- chdir 2 | 3 | / error = chdir(string); 4 | 5 | .globl _chdir 6 | 7 | .data 8 | _chdir: 9 | 1f 10 | .text 11 | 1: 12 | mov 2(sp),0f 13 | clr r0 14 | sys chdir; 0:.. 15 | adc r0 16 | rts pc 17 | 18 | -------------------------------------------------------------------------------- /src/lib/chmod.s: -------------------------------------------------------------------------------- 1 | / C library -- chmod 2 | 3 | / error = chmod(string, mode); 4 | 5 | .globl _chmod 6 | 7 | .data 8 | _chmod: 9 | 1f 10 | .text 11 | 1: 12 | mov 2(sp),0f 13 | mov 4(sp),0f+2 14 | clr r0 15 | sys chmod; 0:..; .. 16 | adc r0 17 | rts pc 18 | 19 | -------------------------------------------------------------------------------- /src/lib/chown.s: -------------------------------------------------------------------------------- 1 | / C library -- chown 2 | 3 | / error = chown(string, owner); 4 | 5 | .globl _chown 6 | 7 | .data 8 | _chown: 9 | 1f 10 | .text 11 | 1: 12 | mov 2(sp),0f 13 | mov 4(sp),0f+2 14 | clr r0 15 | sys chown; 0:..; .. 16 | adc r0 17 | rts pc 18 | 19 | -------------------------------------------------------------------------------- /src/lib/close.s: -------------------------------------------------------------------------------- 1 | / C library -- close 2 | 3 | /error = close(file); 4 | 5 | .globl _close 6 | 7 | .data 8 | _close: 9 | 1f 10 | .text 11 | 1: 12 | mov 2(sp),r0 13 | clr r1 14 | sys close 15 | adc r1 16 | mov r1,r0 17 | rts pc 18 | 19 | -------------------------------------------------------------------------------- /src/lib/creat.s: -------------------------------------------------------------------------------- 1 | / C library -- creat 2 | 3 | / file = creat(string, mode); 4 | / 5 | / file == -1 if error 6 | 7 | .globl _creat 8 | 9 | .data 10 | _creat: 11 | 1f 12 | .text 13 | 1: 14 | mov 2(sp),0f 15 | mov 4(sp),0f+2 16 | sys creat; 0:..; .. 17 | bec 1f 18 | mov $-1,r0 19 | 1: 20 | rts pc 21 | 22 | -------------------------------------------------------------------------------- /src/lib/crt0.s: -------------------------------------------------------------------------------- 1 | / C runtime startoff 2 | 3 | .globl retrn 4 | 5 | .globl _main 6 | 7 | start: 8 | mov $mq,r4 9 | mov sp,r0 10 | mov (r0),-(sp) 11 | tst (r0)+ 12 | mov r0,2(sp) 13 | jsr pc,*_main 14 | clr r0 15 | sys exit 16 | 17 | retrn: 18 | mov r5,sp 19 | mov (sp)+,r5 20 | rts pc 21 | 22 | -------------------------------------------------------------------------------- /src/lib/ctime.s: -------------------------------------------------------------------------------- 1 | / C library -- ctime 2 | 3 | / ctime(v1, v2); 4 | / v1 is input time [2] 5 | / v2 is char[16] ascii time 6 | / format is 0123456789012345 7 | / Mmm dd hh:mm:sse 8 | / 9 | 10 | .globl _ctime 11 | .globl ctime 12 | 13 | .data 14 | _ctime: 15 | 1f 16 | .text 17 | 1: 18 | mov 2(sp),r0 19 | mov (r0)+,-(sp) 20 | mov (r0)+,mq 21 | mov (sp)+,ac 22 | mov 4(sp),r0 23 | clrb 15.(r0) 24 | jsr pc,ctime 25 | rts pc 26 | 27 | -------------------------------------------------------------------------------- /src/lib/execl.s: -------------------------------------------------------------------------------- 1 | / C library -- execl 2 | 3 | / execl(file, arg1, arg2, ... , 0); 4 | / 5 | / 6 | .globl _execl 7 | 8 | .data 9 | _execl: 10 | 1f 11 | .text 12 | 1: 13 | mov 2(sp),0f 14 | mov sp,r0 15 | add $4,r0 16 | mov r0,0f+2 17 | sys exec; 0:..; .. 18 | rts pc 19 | 20 | -------------------------------------------------------------------------------- /src/lib/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 | .globl _execv 9 | 10 | .data 11 | _execv: 12 | 1f 13 | .text 14 | 1: 15 | mov 2(sp),0f 16 | mov 4(sp),0f+2 17 | sys exec; 0:..; .. 18 | rts pc 19 | 20 | -------------------------------------------------------------------------------- /src/lib/exit.s: -------------------------------------------------------------------------------- 1 | / C library -- exit 2 | 3 | / exit(code) 4 | / code is return in r0 to system 5 | 6 | .globl _exit 7 | 8 | .data 9 | _exit: 10 | 1f 11 | .text 12 | 1: 13 | mov 2(sp),r0 14 | sys exit 15 | 16 | -------------------------------------------------------------------------------- /src/lib/fork.s: -------------------------------------------------------------------------------- 1 | / C library -- fork 2 | 3 | / pid = fork(); 4 | / 5 | / pid == 0 in child process; pid == -1 means error return 6 | 7 | .globl _fork 8 | 9 | .data 10 | _fork: 11 | 1f 12 | .text 13 | 1: 14 | sys fork 15 | br 1f 16 | bes 2f 17 | rts pc 18 | 2: 19 | mov $-1,r0 20 | rts pc 21 | 1: 22 | clr r0 23 | rts pc 24 | 25 | -------------------------------------------------------------------------------- /src/lib/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 10 | 11 | .data 12 | _fstat: 13 | 1f 14 | .text 15 | 1: 16 | mov 2(sp),r0 17 | mov 4(sp),0f 18 | sys fstat; 0:.. 19 | bec 1f 20 | mov $1,r0 21 | rts pc 22 | 1: 23 | clr r0 24 | rts pc 25 | 26 | -------------------------------------------------------------------------------- /src/lib/getchr.s: -------------------------------------------------------------------------------- 1 | / C library -- getchar 2 | 3 | .globl _getchar 4 | .globl _fin 5 | 6 | .globl getc 7 | 8 | .data 9 | _getchar: 10 | 1f 11 | .text 12 | 1: 13 | jsr r5,getc; _fin 14 | bcs 1f 15 | tst r0 16 | beq 1b 17 | rts pc 18 | 1: 19 | clr r0 20 | rts pc 21 | 22 | .bss 23 | _fin: .=.+518. 24 | 25 | -------------------------------------------------------------------------------- /src/lib/getuid.s: -------------------------------------------------------------------------------- 1 | / C library -- getuid 2 | 3 | / uid = getuid(); 4 | / 5 | / uid == -1 if error 6 | 7 | .globl _getuid 8 | 9 | .data 10 | _getuid: 11 | 1f 12 | .text 13 | 1: 14 | sys getuid 15 | bec 1f 16 | mov $-1,r0 17 | rts pc 18 | 1: 19 | bic $!377,r0 20 | rts pc 21 | 22 | -------------------------------------------------------------------------------- /src/lib/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 9 | 10 | .data 11 | _gtty: 12 | 1f 13 | .text 14 | 1: 15 | mov 2(sp),r0 16 | mov 4(sp),0f 17 | sys gtty; 0:.. 18 | bes 1f 19 | clr r0 20 | rts pc 21 | 1: 22 | mov $1,r0 23 | rts r0 24 | 25 | -------------------------------------------------------------------------------- /src/lib/intr.s: -------------------------------------------------------------------------------- 1 | / C library -- intr 2 | 3 | / intr(0); /* exit on interrupt */ 4 | / intr(anything_odd); /* ignore interrupts */ 5 | / intr(label); /* goto label on interrupts */ 6 | 7 | .globl _intr 8 | 9 | .data 10 | _intr: 11 | 1f 12 | .text 13 | 1: 14 | mov 2(sp),r0 15 | beq 1f 16 | bit $1,r0 17 | beq 2f 18 | 1: 19 | bic $1,r0 20 | mov r0,0f 21 | sys intr; 0:.. 22 | rts pc 23 | 2: 24 | mov r5,9f 25 | mov r0,9f+2 26 | sys intr; 1f 27 | rts pc 28 | 29 | / here on interrupts 30 | 31 | 1: 32 | mov 9f,r5 33 | jmp *9f+2 34 | 35 | .bss 36 | 9: 37 | .=.+4 38 | 39 | -------------------------------------------------------------------------------- /src/lib/link.s: -------------------------------------------------------------------------------- 1 | / C library -- link 2 | 3 | / error = link(old-file, new-file); 4 | / 5 | 6 | .globl _link 7 | 8 | .data 9 | _link: 10 | 1f 11 | .text 12 | 1: 13 | mov 2(sp),0f 14 | mov 4(sp),0f+2 15 | clr r0 16 | sys link; 0:..; .. 17 | adc r0 18 | rts pc 19 | 20 | -------------------------------------------------------------------------------- /src/lib/makdir.s: -------------------------------------------------------------------------------- 1 | / C library -- makdir 2 | 3 | / error = makdir(string); 4 | 5 | .globl _makdir 6 | 7 | .data 8 | _makdir: 9 | 1f 10 | .text 11 | 1: 12 | mov 2(sp),0f 13 | clr r0 14 | sys makdir; 0:.. 15 | adc r0 16 | rts pc 17 | 18 | -------------------------------------------------------------------------------- /src/lib/open.s: -------------------------------------------------------------------------------- 1 | / C library -- open 2 | 3 | / file = open(string, mode) 4 | / 5 | / file == -1 means error 6 | 7 | .globl _open 8 | 9 | .data 10 | _open: 11 | 1f 12 | .text 13 | 1: 14 | mov 2(sp),0f 15 | mov 4(sp),0f+2 16 | sys open; 0:..; .. 17 | bec 1f 18 | mov $-1,r0 19 | 1: 20 | rts pc 21 | 22 | -------------------------------------------------------------------------------- /src/lib/printf.c: -------------------------------------------------------------------------------- 1 | printn(n,b) { 2 | extern putchar; 3 | auto a; 4 | 5 | if(a=n/b) /* assignment, not test for equality */ 6 | printn(a, b); /* recursive */ 7 | putchar(n%b + '0'); 8 | } 9 | 10 | printf(fmt,x1,x2,x3,x4,x5,x6,x7,x8,x9) 11 | char fmt[]; 12 | { 13 | extern printn, putchar; 14 | char s[]; 15 | auto adx[], x, c; 16 | 17 | adx = &x1; /* argument pointer */ 18 | loop: 19 | while((c = *fmt++) != '%') { 20 | if(c == '\0') 21 | return; 22 | putchar(c); 23 | } 24 | x = *adx++; 25 | switch (c = *fmt++) { 26 | 27 | case 'd': /* decimal */ 28 | case 'o': /* octal */ 29 | if(x < 0) { 30 | x = -x; 31 | if(x<0) { /* is - infinity */ 32 | if(c=='o') 33 | printf("100000"); 34 | else 35 | printf("-32768"); 36 | goto loop; 37 | } 38 | putchar('-'); 39 | } 40 | printn(x, c=='o'?8:10); 41 | goto loop; 42 | 43 | case 'c': /* char */ 44 | putchar(x); 45 | goto loop; 46 | 47 | case 's': /* string */ 48 | s = x; 49 | while(c = *s++) 50 | putchar(c); 51 | goto loop; 52 | } 53 | putchar('%'); 54 | fmt--; 55 | adx--; 56 | goto loop; 57 | } 58 | 59 | -------------------------------------------------------------------------------- /src/lib/putchr.s: -------------------------------------------------------------------------------- 1 | / C library -- putchar 2 | 3 | / char = putchar(char) 4 | 5 | / buffer output if fout is not 1 6 | 7 | .globl _putchar 8 | .globl _fout 9 | .globl _flush 10 | 11 | .globl putc 12 | .globl flush 13 | 14 | .data 15 | _putchar: 16 | 1f 17 | .text 18 | 1: 19 | mov 2(sp),r0 20 | tst _fout 21 | bne 1f 22 | mov $1,_fout 23 | 1: 24 | jsr r5,putc; _fout 25 | movb 3(sp),r0 26 | beq 1f 27 | jsr r5,putc; _fout 28 | 1: 29 | cmp _fout,$1 30 | bne 1f 31 | jsr r5,flush; _fout 32 | 1: 33 | mov 2(sp),r0 34 | rts pc 35 | 36 | .data 37 | _flush: 38 | 1f 39 | .text 40 | 1: 41 | jsr r5,flush; _fout 42 | rts pc 43 | 44 | .bss 45 | _fout: .=.+518. 46 | 47 | -------------------------------------------------------------------------------- /src/lib/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 8 | 9 | .data 10 | _read: 11 | 1f 12 | .text 13 | 1: 14 | mov 2(sp),r0 15 | mov 4(sp),0f 16 | mov 6(sp),0f+2 17 | sys read; 0:..; .. 18 | bec 1f 19 | mov $-1,r0 20 | 1: 21 | rts pc 22 | 23 | -------------------------------------------------------------------------------- /src/lib/seek.s: -------------------------------------------------------------------------------- 1 | / C library -- seek 2 | 3 | / error = seek(file, offset, ptr); 4 | 5 | .globl _seek 6 | 7 | .data 8 | _seek: 9 | 1f 10 | .text 11 | 1: 12 | mov 2(sp),r0 13 | mov 4(sp),0f 14 | mov 6(sp),0f+2 15 | sys seek; 0:..; .. 16 | bec 1f 17 | mov $1,r0 18 | rts r0 19 | 1: 20 | clr r0 21 | rts pc 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/lib/setuid.s: -------------------------------------------------------------------------------- 1 | / C library -- setuid 2 | 3 | / error = setuid(uid); 4 | 5 | .globl _setuid 6 | 7 | .data 8 | _setuid: 9 | 1f 10 | .text 11 | 1: 12 | mov 2(sp),r0 13 | sys setuid 14 | bec 1f 15 | mov $1,r0 16 | rts pc 17 | 1: 18 | clr r0 19 | rts pc 20 | 21 | -------------------------------------------------------------------------------- /src/lib/stat.s: -------------------------------------------------------------------------------- 1 | / C library -- stat 2 | 3 | / error = stat(string, statbuf); 4 | 5 | / int statbuf[17] or 6 | / char statbuf[34] 7 | / as appropriate 8 | 9 | .globl _stat 10 | 11 | .data 12 | _stat: 13 | 1f 14 | .text 15 | 1: 16 | mov 2(sp),0f 17 | mov 4(sp),0f+2 18 | sys stat; 0:..; .. 19 | bec 1f 20 | mov $1,r0 21 | rts pc 22 | 1: 23 | clr r0 24 | rts pc 25 | 26 | -------------------------------------------------------------------------------- /src/lib/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 9 | 10 | .data 11 | _stty: 12 | 1f 13 | .text 14 | 1: 15 | mov 2(sp),r0 16 | mov 4(sp),0f 17 | sys stty; 0:.. 18 | bes 1f 19 | clr r0 20 | rts pc 21 | 1: 22 | mov $1,r0 23 | rts pc 24 | 25 | -------------------------------------------------------------------------------- /src/lib/switch.s: -------------------------------------------------------------------------------- 1 | / C library -- switch 2 | 3 | .globl bswitch 4 | 5 | bswitch: 6 | mov *(sp)+,r1 7 | 1: 8 | cmp (r1)+,r0 9 | beq 1f 10 | tst (r1)+ 11 | bne 1b 12 | 2: 13 | mov -4(r1),pc 14 | 1: 15 | mov (r1)+,r0 16 | beq 2b 17 | mov r0,pc 18 | 19 | -------------------------------------------------------------------------------- /src/lib/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 | .data 10 | _time: 11 | 1f 12 | .text 13 | 1: 14 | mov 2(sp),r0 15 | sys time 16 | mov ac,(r0) 17 | mov mq,2(r0) 18 | rts pc 19 | 20 | -------------------------------------------------------------------------------- /src/lib/unlink.s: -------------------------------------------------------------------------------- 1 | / C library -- unlink 2 | 3 | / error = unlink(string); 4 | / 5 | 6 | .globl _unlink 7 | 8 | .data 9 | _unlink: 10 | 1f 11 | .text 12 | 1: 13 | mov 2(sp),0f 14 | clr r0 15 | sys unlink; 0:.. 16 | adc r0 17 | rts pc 18 | 19 | -------------------------------------------------------------------------------- /src/lib/wait.s: -------------------------------------------------------------------------------- 1 | / C library -- wait 2 | 3 | / pid = wait(); 4 | / or, 5 | / pid = wait(&status); 6 | / 7 | / pid == -1 if error 8 | / status idicates fate of process, if given 9 | 10 | .globl _wait 11 | 12 | .data 13 | _wait: 14 | 1f 15 | .text 16 | 1: 17 | clr mq 18 | sys wait 19 | bec 1f 20 | mov $-1,r0 21 | rts pc 22 | 1: 23 | cmp *(sp),tstins / arg count 24 | bne 1f 25 | mov mq,*2(sp) / status return 26 | 1: 27 | rts pc 28 | 29 | tstins: tst (sp)+ / stack pop for 1 arg 30 | 31 | -------------------------------------------------------------------------------- /src/lib/write.s: -------------------------------------------------------------------------------- 1 | / C library -- write 2 | 3 | / nwritten = write(file, buffer, count); 4 | / 5 | / nwritten == -1 means error 6 | 7 | .globl _write 8 | 9 | .data 10 | _write: 11 | 1f 12 | .text 13 | 1: 14 | mov 2(sp),r0 15 | mov 4(sp),0f 16 | mov 6(sp),0f+2 17 | sys write; 0:..; .. 18 | bec 1f 19 | mov $-1,r0 20 | 1: 21 | rts pc 22 | 23 | -------------------------------------------------------------------------------- /tools/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS=-g -Wall 2 | 3 | all: pdp11 mkfs ml apout/apout 4 | 5 | pdp11: simh/makefile 6 | $(MAKE) -C simh NOVIDEO=1 pdp11 7 | ln -sf simh/BIN/pdp11 . 8 | 9 | simh/makefile: 10 | git submodule update --init 11 | 12 | mkfs: mkfs.c 13 | 14 | ml: ml.c 15 | 16 | apout/apout: 17 | ($(MAKE) -C apout; rm -f apout/*.o) 18 | 19 | clean: 20 | rm -f pdp11 21 | $(MAKE) -C simh clean 22 | rm -f mkfs ml 23 | $(MAKE) -C apout clean 24 | -------------------------------------------------------------------------------- /tools/as: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # use the v2 assembler to assemble some userland code into an 0405 binary. 4 | # Requires the first .s file to set ". = . + 40014". 5 | # 6 | # example, mount.s: 7 | # exit = 1. 8 | # write = 4. 9 | # mount = 21. 10 | # .. = 40014 11 | # 12 | # mov $1,r0 13 | # sys write; rk0; 8. 14 | # sys write; usr; 4. 15 | # sys mount; rk0; usr 16 | # sys exit 17 | # sys exit 18 | # 19 | # rk0: 20 | # usr: 21 | # 22 | # $ tools/as mount.s 23 | # $ cp b.out mymount 24 | # 25 | 26 | APOUT=tools/apout/apout 27 | APOUT_ROOT=fs/root 28 | export APOUT_ROOT 29 | $APOUT $APOUT_ROOT/bin/as "$@" && tools/fixaout.py 30 | 31 | 32 | -------------------------------------------------------------------------------- /tools/assemv2: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # assemble the sources 4 | # 5 | if [ ! -d tools ] 6 | then echo 'No tools/ directory, are you running this in the correct dir?' 7 | exit 1 8 | fi 9 | if [ ! -f tools/pdp11 ] 10 | then echo 'You need to compile Simh with the ke11 patch, and place the' 11 | echo 'resulting pdp11 executable into the tools/ directory.' 12 | exit 1 13 | fi 14 | if [ ! -f tools/apout/apout ] 15 | then echo 'You need to go into tools/apout/ and do a make to compile apout' 16 | exit 1 17 | fi 18 | if [ ! -d build ] 19 | then mkdir build 20 | fi 21 | 22 | APOUT=../tools/apout/apout 23 | APOUT_ROOT=../fs/root 24 | export APOUT_ROOT 25 | 26 | # Build sources from pages and generate patched sources in "build". 27 | # Any command-line args are names of patch files in patches/, but without 28 | # the trailing .patch. If "nopatch" is the first command-line argument, 29 | # then no patches will be applied, and build/ is expected to already have 30 | # the patched kernel code. 31 | if [ ! "$1" = "nopatch" ] 32 | then tools/rebuild "$@" 33 | fi 34 | 35 | # assemble the kernel from patched sources and generate symbols 36 | # and build a simh loadable file. 37 | cd build 38 | 39 | # assemble it all 40 | $APOUT $APOUT_ROOT/bin/as u?.s 41 | $APOUT $APOUT_ROOT/bin/nm a.out |sort > a.out.syms 42 | ../tools/ml 43 | 44 | -------------------------------------------------------------------------------- /tools/disaout/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS = -g -Wall 2 | 3 | disaout: main.o aout.o magic.o opset.o syscalls.o symbols.o 4 | cc -o disaout main.o aout.o magic.o opset.o syscalls.o symbols.o 5 | 6 | clean: 7 | rm -f disaout *.o 8 | -------------------------------------------------------------------------------- /tools/disaout/README: -------------------------------------------------------------------------------- 1 | This is a start on a disassembler for PDP-11 a.out Unix binaries. There's 2 | still a lot to do. Right now I am concentrating on V1 and V2 binaries. I 3 | have re-used code from Apout, so later on we can also do binaries from 4 | V5/B6/V7, 2.9 and 2.11 BSD. I'd also like to parse symbol tables, but 5 | that's for later. 6 | 7 | I need to deal with the bss and initialised data sections of a binary. 8 | 9 | Lots to do, and it's very frustrating. 10 | 11 | Warren Toomey, Mon May 5 2008 12 | -------------------------------------------------------------------------------- /tools/disaout/main.c: -------------------------------------------------------------------------------- 1 | #include "aout.h" 2 | 3 | extern int load_a_out(const char *file, struct exec *E); 4 | extern int printins(int addr); 5 | extern void patch_symbols(void); 6 | extern void print_symtables(void); 7 | extern u_int8_t *ispace, *dspace; /* Instruction and Data spaces */ 8 | extern int doprint; 9 | int onepass = 0; /* Only do a single pass */ 10 | int printaddrs = 0; /* Print out addresses and words */ 11 | 12 | void dopass(struct exec *e) 13 | { 14 | u_int16_t *iptr; 15 | for (int i = e->a_entry; i < e->a_entry + e->a_text;) { 16 | iptr = (u_int16_t *) &ispace[i]; 17 | if (doprint && printaddrs) 18 | printf("%06o: %06o\t", i, *iptr); 19 | i += printins(i); 20 | } 21 | } 22 | 23 | void usage() 24 | { 25 | fprintf(stderr, "Usage: disaout [-1a] file\n"); 26 | exit(1); 27 | } 28 | 29 | int main(int argc, char *argv[]) 30 | { 31 | struct exec E; 32 | int ch, err; 33 | 34 | /* Get any arguments */ 35 | while ((ch = getopt(argc, argv, "1a")) != -1) { 36 | switch (ch) { 37 | case '1': 38 | onepass = 1; 39 | break; 40 | case 'a': 41 | printaddrs = 1; 42 | break; 43 | case '?': 44 | default: 45 | usage(); 46 | } 47 | } 48 | argc -= optind; 49 | argv += optind; 50 | 51 | /* Check we have an file to open */ 52 | if (argc != 1) 53 | usage(); 54 | 55 | /* Get the header details for the a.out file */ 56 | err = load_a_out(argv[0], &E); 57 | 58 | if (err == -1) { 59 | fprintf(stderr, "%s does not appear to be a PDP-11 a.out file\n", 60 | argv[0]); 61 | exit(1); 62 | } 63 | 64 | printf("/ text at 0%o, len 0%o, end 0%o\n", E.a_entry, E.a_text, 65 | E.a_entry + E.a_text); 66 | 67 | if (onepass == 0) { 68 | doprint = 0; 69 | dopass(&E); /* Do pass 1 to infer symbols */ 70 | patch_symbols(); 71 | /* print_symtables(); */ 72 | } 73 | doprint = 1; 74 | dopass(&E); /* Do pass 2 to print it out */ 75 | 76 | exit(0); 77 | } 78 | -------------------------------------------------------------------------------- /tools/fixaout.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """ 3 | Convert an 0407 binary into an 0405 binary, under the assumption 4 | that the code starts at 040014 (by ".. = 40014"). 5 | See tools/as. 6 | """ 7 | 8 | import struct 9 | from io import open 10 | 11 | def words(bs) : 12 | l = len(bs) / 2 13 | return list(struct.unpack('<%dH' % l, bs)) 14 | def unwords(ws) : 15 | l = len(ws) 16 | return struct.pack('<%dH' % l, *ws) 17 | 18 | def read(fn) : 19 | f = open(fn, 'rb') 20 | d = f.read() 21 | f.close() 22 | return d 23 | 24 | def write(fn, d) : 25 | f = open(fn, 'wb') 26 | f.write(d) 27 | f.close() 28 | 29 | d1 = words(read('a.out')) 30 | hdr = d1[:8] 31 | d = [0o405, 12+hdr[1], 0, 0, hdr[4], 0] + d1[8:] 32 | write("a.out", unwords(d)) 33 | -------------------------------------------------------------------------------- /tools/imgbuild: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Build rf0.dsk and rk0.dsk filesystem images from the files in fs/. 4 | # At present there are no command-line options. 5 | 6 | rf_img=rf0.dsk 7 | rk_img=rk0.dsk 8 | 9 | if [ ! -d fs ] 10 | then echo 'No fs/ directory, are you running this in the correct dir?'; exit 1 11 | fi 12 | if [ ! -d build ] 13 | then mkdir build 14 | fi 15 | if [ ! -x tools/mkfs ] 16 | then echo "tools/mkfs doesn't exist, looks like you need to compile it"; exit 1 17 | fi 18 | 19 | # Remove any existing build/root and build/usr 20 | rm -rf build/root build/usr 21 | 22 | # Copy the original files into build. 23 | cp -R fs/root build 24 | cp -R fs/usr build 25 | 26 | # Update certain files as required 27 | cp -R -f fs/new/etc build/root 28 | 29 | # Now build the two images 30 | tools/mkfs -p fs/Readme build/root $rf_img rf 31 | tools/mkfs -p fs/Readme build/usr $rk_img rk 32 | -------------------------------------------------------------------------------- /tools/rebuild: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | r() { cat pages/$2-* > rebuilt/$1.s; } 4 | 5 | rebuild() { 6 | test -d rebuilt || mkdir rebuilt 7 | 8 | echo rebuilding... 9 | r u0 e00 10 | r u1 e01 11 | r u2 e02 12 | r u3 e03 13 | r u4 e04 14 | r u5 e05 15 | r u6 e06 16 | r u7 e07 17 | r u8 e08 18 | r u9 e09 19 | r ux e10 20 | r sh e11 21 | r init e12 22 | } 23 | 24 | corep() { 25 | for x in ../patches/core/*.patch ; do 26 | y=`basename $x .patch` 27 | echo ' ' $y; patch -s -p1 < $x 28 | done 29 | } 30 | 31 | p() { echo ' ' $1; patch -s -p1 <../patches/$1.patch; } 32 | 33 | patches() { 34 | test -d build || mkdir build 35 | 36 | echo patching... 37 | cp rebuilt/* build 38 | cd build 39 | corep 40 | for x in "$@" ; do 41 | p $x 42 | done 43 | } 44 | 45 | 46 | rebuild 47 | patches "$@" 48 | -------------------------------------------------------------------------------- /tools/rebuild-split: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # rebuild sources in a manner that lets you see the page splits. 3 | # useful for editing the pages to get the inter-page flow to line 4 | # up properly. 5 | 6 | xcat() { 7 | for fn in $*; do 8 | cat $fn 9 | echo "******* $fn end *******" 10 | done 11 | } 12 | 13 | m() { xcat pages/$2 > rebuilt/$1.s; } 14 | 15 | test -d rebuilt || mkdir rebuilt 16 | 17 | m u0 e00-* 18 | #m u1 e01-* 19 | m u2 e02-* 20 | #m u3 e03-* 21 | #m u4 e04-* 22 | m u5 e05-* 23 | m u6 e06-* 24 | m u7 e07-* 25 | #m u8 e08-* 26 | m u9 e09-* 27 | m ux e10-* 28 | #m sh e11-* 29 | #m ini e12-* 30 | -------------------------------------------------------------------------------- /tools/tap: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # build a tape for simh containing the kernel sources 4 | # requires conv2.c to be built 5 | 6 | UNIXDIR=~/work/simh/unix-v7-4/run 7 | 8 | tools/rebuild 9 | (cd rebuilt; gtar -O -cf ../u.tar u?.s) 10 | tools/conv2 -o tape.tm u.tar 11 | cp tape.tm $UNIXDIR 12 | --------------------------------------------------------------------------------